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

GRADE PROBLEM 1. Write a program that repeatedly prompts the user for the testl,

ID: 3891308 • Letter: G

Question

GRADE PROBLEM 1. Write a program that repeatedly prompts the user for the testl, test2 as well as the semester grade or both based upon the choice of the user. Calculate the numeric follows (Spring, Summer, Fall) and for output displays the numerical or letter al grade as If Spring grade- (testl+2+test2)/3 If Summer grade- (test1+test2) /2 grade= (Test1+test2-2) /3 Make sure to write the problem in a void method called gradeProblem (). Keep the problem repeating using a menu. 30Pts SAMPLE RUN Grade Menu 1. Numerical Grade 2. Letter Grade 3. Both 4. Exit Choice:3 En ter Testi: 100 nter Test2 : 80 Semester: sunmer Numerical Grade: 90 Letter Grade: A Grade Menu . Numerical Grade 2. Letter Grade 3. Both 4. Exit Choice:4

Explanation / Answer

code:

import java.util.Scanner;

public class Grade {
//for displaying the grade
public static void gradeProblem(int test1, int test2, String Semester,int ch){
double grade=0;
//calculates the grade based on the semester
if(Semester.equalsIgnoreCase("SPRING")){
grade = (test1*2+test2)/3;
}
else if(Semester.equalsIgnoreCase("SUMMER")){
grade = (test1+test2)/2;
}
else if(Semester.equalsIgnoreCase("FALL")){
grade = (test1+test2*2)/3;
}
else{
System.out.print(" plz ..Enter the Semester (summer, spring or fall..");
return;
}
//display the numnerical grade
if((ch==1)||(ch==3)){
System.out.print(" Numerical grade :"+grade);

}
//display the letter grade
if ((ch == 2)||(ch==3)){
char letterGrade;
if(grade >=90){
letterGrade= 'A';
}
else if(grade >=80){
letterGrade= 'B';
}
else if(grade >=70){
letterGrade= 'C';
}
else {
letterGrade= 'D';
}
System.out.print(" Letter Grade :"+ letterGrade);
}

}
public static void main(String[] args){
  
Scanner input = new Scanner(System.in);

int choice;
int test1, test2;
String semester;
do{
  
//display the menu
System.out.print(" Grade Menu");
System.out.print(" 1.Numerical Grade 2.Letter Grade 3.Both 4.Exit");
System.out.print(" Choice : ");
  
//accept the user input
choice = input.nextInt();
  
//select the operation to be performed
switch(choice){
case 1:
case 2:
case 3:
System.out.print(" Enter the Test1 :");
test1 = input.nextInt();
System.out.print(" Enter the Test2 :");
test2 = input.nextInt();
System.out.print(" semester :");
semester = input.next();
gradeProblem(test1, test2,semester,choice);
break;
case 4:
System.out.print(" Thank you for using this program");
break;
default:
System.out.print(" plz...Enter the choice from 1-4");
  
}
  
}while(choice!=4);//perform until exit as choice
  
}
}

Output:

Grade Menu
1.Numerical Grade
2.Letter Grade
3.Both
Exit
Choice : 2

Enter the Test1 :100

Enter the Test2 :80

semester :spring

Letter Grade :A
Grade Menu
1.Numerical Grade
2.Letter Grade
3.Both
Exit
Choice : 4

Thank you for using this program