Question: Declare a String variable to store the user's name and a double to store their grade entered from the keyboard. Modify the main method to
- Declare a String variable to store the user's name and a double to store their grade entered from the keyboard. Modify the main method to have the program displays their name in the output.
- Your changes will only be made in the main method.
- The output would look like this:
- Hello, please tell me your first name: Grace Grace, please enter your percentage: 62.3 Grace, a 62.3 is a D
- Hello, please tell me your first name: Grace Grace, please enter your percentage: 62.3 Grace, a 62.3 is a D
public class TestVoidMethod { public static void main(String[] args) { System.out.print("The grade is "); printGrade (78.5); System.out.print("The grade is "); printGrade (59.5); 9 10 11 public static void printGrade (double score) { if (score >= 90.0) { System.out.println('A'); 12 73 14 else if (score >= 80.0) { System.out.println('B'); 15 16 17 else if (score >= 70.0) { System.out.println('C'); 18 19 20 else if (score >= 60.0) { System.out.println('D'); 21 22 23 24 else { System.out.println('F'); } 25 26 27 } } The grade is C The grade is F
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
