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

1) Write a program using the switch statement name GradeReport that reads a grad

ID: 3682783 • Letter: 1

Question

1) Write a program using the switch statement name GradeReport that reads a grade from the user and prints the comments accordingly. Instruction: Prompt the user to enter their grade user must be prompt to enter a numeric grade (0 to 100) if the input isn't an integer between 0 and 100, prompt the user to re-enter Use a do loop for the re-enter of grade then if condition is not met or grade is not between 0 and 100 then prompt the user on the screen as follows ("Error: You must enter an integer between 0 and 100");” Also incorporate a while loop to keep track of tries. create a variable name “tries” that will keep track of tries no more than 3 therefore if the input isn't an integer between 0 and 100, prompt the user to reenter

Explanation / Answer

import java.util.Scanner;

public class GradeReport {

   public static void main(String[] args) {
      
       Scanner sc = new Scanner(System.in);
      
       int tries = 1;
       int grade;
      
       do{
          
           System.out.print("Enter your grade point: ");
           grade = sc.nextInt();
           if(grade < 0 || grade>100){
               System.out.println("Error: You must enter an integer between 0 and 100");
               tries++;
           }
           else{
               System.out.println("Hi, your grade point is "+grade);
               break;
           }
       }while(tries<=3);
      
       if(tries==4){
           System.out.println("You have attempted upto max limit");
       }
   }
}