Question: (JAVA CODNG ) The question is below the code: import java.util.*; public class Homework{ public static void main(String[] args) { String name; String id; String

(JAVA CODNG )

The question is below the code:

import java.util.*;

public class Homework{

public static void main(String[] args)

{

String name;

String id;

String grade;

double score;

String response;

Scanner a = new Scanner(System.in);

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

System.out.println("Welcome to Grading System Program!");

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

System.out.println("");

while(response == "YES")

{

System.out.print("Please enter your name (Lastname, Firstname seperated by a comma): ");

name=a.nextLine();

while( !(name.length() >1 &&name.contains((","))==true))

{

System.out.println("");

System.out.print("Please enter your name (Lastname, Firstname seperated by a comma): ");

name=a.nextLine();

}

String nameArr[]=name.split(",");

name=nameArr[1] + " " + nameArr[0];

System.out.println("");

System.out.print("Please enter your ID without any spaces (7 digits): ");

id=a.nextLine();

while(!(id.length()==7))

{

System.out.println("");

System.out.print("Please enter your ID without any spaces (7 digits): ");

id=a.nextLine();

}

System.out.println("");

System.out.print("Please enter your score (0-100) ");

score=a.nextInt();

if(!(score>=0 && score <=100))

{

System.out.println("");

System.out.println("Please enter your score (0-100): ");

score=a.nextInt();

}

System.out.println("");

System.out.println(name +" got "+ score +"!");

if(score >= 80)

{

grade="A";

System.out.println("");

System.out.println("Based on the grading system, " + nameArr[1]+"("+id+") will probably get "+grade+"! Congratulations!");

}

else if(score>=70)

{

grade="B";

System.out.println("");

System.out.println("Based on the grading system, " + nameArr[1]+"("+id+") will probably get "+grade+"! Keep up the good work!");

}

else if(score>=60)

{

grade="C";

System.out.println("");

System.out.println("Based on the grading system, " + nameArr[1]+"("+id+") will probably get "+grade+"! You can do a lot better!");

}

else

{

grade="FNS";

System.out.println("");

System.out.print("Based on the grading system, " + nameArr[1]+"("+id+") will probably get "+grade+"! Please work harder to pass the course!");

}

}

System.out.println("Want to Exit?");

response=a.nextLine();

}

}

Here, I am trying to indicate that, at the end of the output, the respondent will have a question such as "Want to exit?"

I want the program to say that if you type ANYTHING OTHER THAN YES, the program will loop, and it will ask the question, Please enter your name again and again. However, if the user puts YES, the program will terminate.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!