206k views
4 votes
Write a program that is called "GradeReport" this program must incorporate the use of the following: 1) User input 2) if statements 3) While loop This program reads the user input for a grade and prints the comments accordingly. Please ensure that your program can handle inputs such as 91, 92, 105, -1 and so forth. Your program should prompting the user 3 times if user enters bad/invalid data and be user friendly which will alert the user of their wrong doing immediately after the 3rd time please ask the user (Do you want to continue yes or no) if yes you should send the user back thru the code. Incorporated the use of the equalsIgnoreCase () method to take in all inputs whether it’s A or a.

1 Answer

0 votes

Answer:

import java.util.*;

class GradeReport

{

public static void main(String args[])

{

int grade,c=0;

String yesNo,gradeR="";

Scanner input=new Scanner(System.in);

while(true)

{

System.out.print("\\Enter Grade: ");

grade=input.nextInt();

if(grade>100 || grade<0)

{

System.out.println("\\\\You have entered the wrong input!!\\");

System.out.print("Do you want to continue yes or no: ");

yesNo=input.next();

if(yesNo.equalsIgnoreCase("no"))

{

break;

}

}

else

{

c++;

gradeR=gradeR+c+" : "+grade+"\\";

if(c==3)

{

break;

}

}

}

System.out.println("\\\\Three Valid grades are : \\");

System.out.println(gradeR);

System.out.println("\\");

}

}

User Nyte
by
5.2k points