Below is a java program that inputs an integer grade and turns it into a letter grade.
Update the below java code as follows and comment each line to explain what is happening:
1. Convert the if-else-if code block to a switch statement to solve the problem.
2. Use modulus to convert the grade input so that the range of grades are converted to one value. (comment the line)
import java.util.Scanner;
public class GradeLetterTest {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter integer grade");
String s = "";
char c ;
int grade = scan.nextInt();
if(grade<0 || grade > 100) {
s ="ERROR You have entered an invalid input";
System.out.println(s);
} else {
if(grade>=90) {
c = 'A';
} else if(grade>=80 && grade<90) {
c = 'B';
} else if(grade>=70 && grade<80) {
c = 'C';
} else if(grade>=60 && grade<70) {
c = 'D';
} else {
c='F';
}
System.out.printf("You have earned the letter grade: %c\n",c);
}
}
}
Dear Student,
below i have modified the given Java program as per the requirement.
Please note that the below program is tested on ubuntu 14.04 sytem and compiled in javac compiler. This program will also work on other IDE's
================================================================
Program:
================================================================
import java.util.Scanner;
public class GradeLetterTest
{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter integer grade");
String s = "";
char c ;
int grade = scan.nextInt();
//here we have divded the input grade by 10 to convert into one digit
int input = grade/10;
//here we are switiching to each case
switch(input)
{
//if input is 10 or 9 grade is A
case 10:
case 9:
c = 'A';
System.out.printf("You have earned the letter grade: %c\n",c);
break;
//if input is 8 grade is B
case 8:
c = 'B';
System.out.printf("You have earned the letter grade: %c\n",c);
break;
//if input is 7 grade is C
case 7:
c = 'C';
System.out.printf("You have earned the letter grade: %c\n",c);
break;
//if input is 6 grade is D
case 6:
c = 'D';
System.out.printf("You have earned the letter grade: %c\n",c);
break;
//cases if grade is F
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
c = 'F';
System.out.printf("You have earned the letter grade: %c\n",c);
break;
//if grade is invalid i.e input
default:
s ="ERROR You have entered an invalid input";
System.out.println(s);
break;
}
}
}
================================================================
Sample Outputs:


=================================================================
KIndly Check and Verify Thanks...!!!
Below is a java program that inputs an integer grade and turns it into a letter...
please help me with this problem The following program uses if-else-if statements to determine a letter grade. Rewrite it using if statements with logical operators (&&, ||, !) to produce the same output when given the same inputs. import java.util.Scanner; public class GradeCalculator{ public static void main(String[] args){ int grade; Scanner input = new Scanner(System.in); System.out.println("Enter numeric grade out of 100: "); grade = input.nextInt(); if (grade >= 90){ System.out.println("Congratulations! You got an A!"); } else if (grade >= 80){...
Java programming only Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be...
Complete the following Java program by writing the missing methods. public class 02 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Enter a number: int n = scan.nextInt(); if (isOdd (n)) { //Print n to 1 System.out.println("Print all numbers from "+n+" to 1"); printNumToOne (n); } else { System.out.println(n + " is //End of main()
Part I Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be handled...
Java Programming Language Edit and modify from the given code Perform the exact same logic, except . . . The numeric ranges and corresponding letter grade will be stored in a file. Need error checking for: Being able to open the text file. The data makes sense: 1 text line of data would be 100 = A. Read in all of the numeric grades and letter grades and stored them into an array or arraylist. Then do the same logic....
the code needs to be modifed. require a output for the
code
Java Program to Implement Insertion Sort import java.util.Scanner; /Class InsertionSort * public class Insertion Sort { /Insertion Sort function */ public static void sort( int arr) int N- arr.length; int i, j, temp; for (i-1; i< N; i++) j-i temp arrli; while (j> 0 && temp < arrli-1) arrli]-arrli-1]; j-j-1; } arrlj] temp; /Main method * public static void main(String [] args) { Scanner scan new Scanner( System.in...
Complete the program, Grade.java, below. The program takes in a student's score and prints the corresponding letter grade assuming a standard 60-70-80-90 scale for cutoff of each grade. For example, if a student's score is 52.6 they would be assigned an "F" grade. If a student's score is 87.8 they would be assigned a "B grade. The program should take in the score as a double value and print the letter grade (capitalized letter of A, B, C, D, or...
import java.util.Scanner; public class SCAN { public static void main(String[ ] args) { int x, y, z; double average; Scanner scan = new Scanner(System.in); System.out.println("Enter an integer value"); x = scan.nextInt( ); System.out.println("Enter another integer value"); y = scan.nextInt( ); System.out.println("Enter a third integer value"); z = scan.nextInt( ); average = (x + y + z) / 3; System.out.println("The result of my calculation is " + average); } } What is output if x = 0, y = 1 and...
Write a JAVA program that prompts the user for student grades and displays the highest and lowest grades in the class. The user should enter a character to stop providing values. Starter code: import java.util.Scanner; public class MaxMinGrades{ public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.println("Enter as many student grades as you like. Enter a character to stop."); double grade = input.nextDouble(); double minGrade = Double.MAX_VALUE; double maxGrade = Double.MIN_VALUE; while (Character.isDigit(grade)) { if (grade == 0)...
JAVA: Rewrite the following code to where the inputs are from a file. The file name will be from the input from the user scanner. CODE: import java.util.*; public class Q1 { public static int sumOD (int k) { int sumOD = 0; int in = k; while (in != 0) { int digitON = in % 10; sumOD += digitON; in /= 10; } return sumOD; } public static void main(String[] args) { int n, i, k; System.out.println("Enter...