QUESTION 1 Code an application class called LetterGrade that prints letter grade
ID: 3722578 • Letter: Q
Question
QUESTION 1
Code an application class called LetterGrade that prints letter grades based on a numeric grade. A studentGrade is defined as follows:
1. 90 or above is an "A",
2. 80 or above is a "B",
3. 70 or above is a "C",
4. 60 or above is a "D",
5. anything else is an "F".
Fill in the missing code:
import java.util.;
public class
{
public void (String args)
{
Scanner = new ();
int = ;
System.out.printf("%nEnter your numeric grade as an integer "
"or -1 to exit: ");
studentGrade = input.;
()
{
()
{
System.out.printf("%nYou've earned an A!%n");
}//END if
{
()
{
8: System.out.printf("%nYou've earned a B.%n");
;
case : System.out.printf("%nYou've earned a C.%n");
break;
case 6:
break;
: System.out.printf("%nYou've earned an F.%n");
}//END switch
}//END else
System.out.printf("%nEnter another numeric grade as an integer "
+ "or -1 to exit: ");
= ;
}//END while
System.exit(0);
}//END main()
}//END APPLICATION CLASS LetterGrade
Code an application class called LetterGrade that prints letter grades based on a numeric grade. A studentGrade is defined as follows: . 90 or above is an "A 2. 80 or above isa "B" 3. 70 or above is a "C" 4. 60 or above is a "D" 5. anything else is an "F". Fill in the missing code import java.util. public class public void (String args) Scanner = new int System.out .printf("%nEnter your numeric grade as an integer " or-1 to exit:"); 3tudentGrade = input. sy3tem . out.print f("%nYou've //END 1s earned an A!"); 8: System.out.printf(":nYou've earned a B.%n"); System . out . print f("%nYou've earned c.%n"); case break: case 6: break a : System . out . print f("%nYou've earned an F."); //END switch //END else System.out.printf("nEnter another numeric grade as an integer'" + "or-1 to exit: "); //END while System. exit (0) //END main () //END APPLICATION CLASS LetterGradeExplanation / Answer
import java.util.Scanner;
public class LetterGrade
{
public static void main(String [ ] args)
{
Scanner input = new Scanner(System.in);
int studentGrade = 0;
System.out.printf("%n Enter your numeric grade as an integer"+"or -1 to exit:");
studentGrade = input.nextInt( );
while(input.hasNext( ))
{
if(studentGrade>=90)
{
System.out.printf("%n you've earned an A :%n");
}//END IF
else
{
switch ( studentGrade/10)
{
case 8:System.out.printf("%n you've earned a B.%n");
break;
case 7:System.out.printf("%n you've earned a C.%n");
break;
case 6:System.out.printf("%n you've earned a D%n");
break;
default: System.out.printf("%n you've earned a F.%n);
}//END switch
}//END else
System.out.printf("%n Enter another numeric grade as an integer"+"or -1 to exit:");
studentGrade = input.nextInt( );
}//END while
System.exit(0);
}END main( )
}END APPLICATION CLASS LetterGrade
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.