Answer to Question #16588 in Java | JSP | JSF for Sayed Abdullah Almousawi

Question #16588
Write a Java program that translates a number between 0 and 4 into the closest letter grade according to the shown below Kuwait University Guidelines. For example, the number 2.6 would be converted to C+. Break ties in favor of the better grade (i.e. 2.67 should be a B-).
1
Expert's answer
2012-10-17T09:14:50-0400

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

System.out.print("Enter grade:");

double g = in.nextDouble();

if(g <= 4.0 && g > 3.7)

System.out.println("A");

else if(g <= 3.7 && g > 3.3)

System.out.println("A-");

else if(g <= 3.3 && g > 3.0)

System.out.println("B+");

else if(g <= 3.0 && g > 2.0)

System.out.println("B");

else if(g <= 2.0 && g > 2.7)

System.out.println("B-");

else if(g <= 2.7 && g > 2.3)

System.out.println("C+");

else if(g <= 2.3 && g > 2.0)

System.out.println("C");

else if(g <= 2.0 && g > 1.7)

System.out.println("C-");

else if(g <= 1.7 && g > 1.3)

System.out.println("D+");

else if(g <= 1.3 && g > 1.0)

System.out.println("D");

else if(g <= 1.0 && g > 0.7)

System.out.println("D-");

else if(g <= 0.7 && g > 0)

System.out.println("F");

else

System.out.println("error");

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS