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

P3.13 Write a program (called Grades) that translates a number between 0 and 4 i

ID: 3584689 • Letter: P

Question

P3.13 Write a program (called Grades) that translates a number between 0 and 4 into the closest letter grade. For example, the number 2.8 (which might have been the average of several grades) would be converted to B-. Break ties in favor of the better grade; for example 2.85 should be a B. Here's a sample run of such a program: Enter numeric score then press Enter : 3.85 A Enter numeric score then press Enter : 3.84 A- Enter numeric score then press Enter : 3.5 A- Enter numeric score then press Enter : 3.49 B+ Enter numeric score then press Enter : 3.1 B Enter numeric score then press Enter : 10 A+ Enter numeric score then press Enter : -2 Enter numeric score then press Enter : -0.5

Explanation / Answer

class One { public static void main(String[] m) { } } Now we compile and run. Program runs this time with no error but no output. I now make a change for my program to start solving the problem: class One { public static void main(String[] m) { double n; n = 2.7; if (n > 4.0) { } else { } } } But I would like to let the user know what I discovered: class One { public static void main(String[] m) { double n; n = 2.7; if (n > 4.0) { System.out.println( "Too big" ); } else { if (n < 0) { System.out.println( "Too small" ); } else { System.out.println( "Between A and F" ); } } } } And I'd like to read from the user: class One { public static void main(String[] m) { double n; java.util.Scanner cellPhone = new java.util.Scanner(System.in); System.out.print("Enter the number: "); n = cellPhone.nextDouble(); if (n > 4.0) { System.out.println( "Too big" ); } else { if (n < 0) { System.out.println( "Too small" ); } else { System.out.println( "Between A and F" ); } } } }