Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Code compiles fine but does not give the user a chance to input and prints the d

ID: 3649003 • Letter: C

Question

Code compiles fine but does not give the user a chance to input and prints the defaulut
Below is the code
//import java.util.Scanner;
public class Grade
{

public static void main(String [] args) //double closed barket after string string has to be capitalized
{ // Was a closed braket

int grade = 'A';

switch (grade)

{

case 1:
System.out.println("Awesome Work!"); // removed colon
break;
case 2:
System.out.println("Good Job!");
break;
case 3:
System.out.println("Nice Work!");
break;
case 4:
System.out.println("try harder .try to set time aside to do your class work.");
break;
case 5:
System.out.println("sorry to tell you that you did not get a better grade but we have to let you go.");
break;
default:
System.out.println("Please consider getting help with classes.");
}

}
}

Explanation / Answer

you are not taking any input according to above code.. To take input from keyboard you must use scanner class.. sample code: Scanner scn = new Scanner(System.in); //reading from keyboard String s = scn.nextLine(); //convert string to int int grade = Integer.parseInt(s); now use the grade in switch case accordingly to get correct output.