In: Computer Science
import java.util.Scanner;
public class Grade {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
// Reading score from user
System.out.println("Enter the student's score:");
double score = scnr.nextDouble();
System.out.print("Grade:");
// Checking if score is less than 60
if(score<60){
System.out.println("F");
}
// Checking if score is less than 70
else if(score<70){
System.out.println("D");
}
// Checking if score is less than 80
else if(score<80){
System.out.println("C");
}
// Checking if score is less than 90
else if(score<90){
System.out.println("B");
}
// Checking if score is less than 100
else {
System.out.println("A");
}
}
}
I need this codes output to say
Enter the student's score:
A
and mine says
Enter the student's score:
Grade: A
How do I fix that in my code?
import java.util.Scanner;
public class Grade {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
// Reading score from user
System.out.print("Enter the student's score: ");
double score = scnr.nextDouble();
// Checking if score is less than 60
if(score<60){
System.out.println("F");
}
// Checking if score is less than 70
else if(score<70){
System.out.println("D");
}
// Checking if score is less than 80
else if(score<80){
System.out.println("C");
}
// Checking if score is less than 90
else if(score<90){
System.out.println("B");
}
// Checking if score is less than 100
else {
System.out.println("A");
}
}
}

