I must Utilize the Math class and round the number to zero decimal places, then use the int cast method to convert to an integer.(ensure you round it before type casting it)
Utilize a switch statement to determine the corresponding letter grade. Use the grading criteria from this course for the numbers. (ensure you accept all allowable numbers i.e. 70-79 and all in between)
Output the corresponding letter grade along with the initial number entered in decimal format utilizing the printf method and format specifiers. Output the number in only 3 decimal places.
in my switch
I must Get input for the grade letter in String format.
Utilize a switch statement to determine the corresponding output for the letter entered. (ensure you accept both upper and lower case letters.
Use the grading criteria from this course for the numbers. (you must use charAt( ) so the string will work with your switch)
Output the corresponding numbers values for the letter entered along with the letter initially entered.
Questions I have:
Is my code in the right direction?
Line 15 is giving me problems what I can I do to correct this but still be able create my rounding to the nearest whole number?
Am I missing anything?
public class UribarriMiguelProg4
{
public static void main(String[] args)
{
System.out.println("Welcome to Miguel's Grading Program");
Scanner stdIn = new Scanner (System.in);
char grade;
char letterGrade;
double numericGrade;
System.out.print("Will you be using numbers or letters?");
grade = stdIn.nextLine().charAt(0);
public static RoundingMode valueOf(numericGrade);
while (grade = 'X')
{
System.out.println("Enter a number grade in double format. (Ex. 74.25463)");
numericGrade = stdIn.nextLine ();
if (numbericGrade >=90)
finalLetterGrade ="A";
else
if ((numbericGrade >=80) & (finalNumericGrade <90))
finalLetterGrade ="B";
else
if ((numbericGrade >=70) & (finalNumericGrade <80))
finalLetterGrade ="C";
else
if ((numbericGrade >=60) & (finalNumericGrade <70))
finalLetterGrade ="D";
else
if ((numbericGrade >=0) & (finalNumericGrade <60))
finalLetterGrade ="F";
System.out.println("\nYour Letter Grade Is:\n" + finalLetterGrade);
break;
}
while (grade == 'Y')
{
System.out.print("Enter Yout Letter Grade: ");
letters = stdIn.nextLine ();
switch(letterGrade)
{
case 'A':
System.out.println("90-100 = A");
break;
case 'B':
System.out.println("80-89.9 = B");
break;
case 'C':
System.out.println("70-79.9 = C");
break;
case 'D':
System.out.println("60-69.9 = D");
break;
case 'F':
System.out.println("< 60 = F");
break;
default:
System.out.println("Entered An Incorrect Grade:");
break;
}
}
}
}

New Topic/Question
Reply




MultiQuote





|