Question: JAVA Programming Requirements, Modify and edit from the given code. The numeric ranges for the different grade letters are store in an array or arraylist.

JAVA Programming Requirements,

  1. Modify and edit from the given code.
  2. The numeric ranges for the different grade letters are store in an array or arraylist.
  3. The corresponding grade letters are also in an array or arraylist.
  4. Any array are read-only meaning they are look-up array (the logic should not modify them
  5. Therefore, declare the array as a final static array.
  6. The handing of the invalid numeric value should display the same message.
  7. The output for the grade letter should look the same.

---------------------------------------------------------------------------------------------------------------------

//Given code

import java.util.*;

public class Main { public static void main(String[] args) {

//Get the user input Scanner sc = new Scanner(System.in);

//Loop while(true) { System.out.print("Enter your numeric grade (enter -1 to end the program): "); double grade = sc.nextDouble();

//End the program if user entered -1 if(grade == -1) { System.out.print("The program ended"); break; }

//validating the grade between 0 and 100 if(grade<0 || grade>100)//if user entered invalid input { while(true)//infinity loop to read input untill user enter valid input. { //Displaying error message. System.out.print("You entered inalid numeric grade."); System.out.print("Please enter valid numeric grade from 0-100: "); grade = sc.nextDouble(); //End the validating loop if user entered valid input. if(grade>=0 && grade<=100) { break; } } }

//Convert numeric grade to letter grade if(grade>=93 && grade<=100) System.out.print("Your grade letter is A. "); if(grade>=90 && grade<93) System.out.print("Your grade letter is A-. ");

else if(grade>=87 && grade<90) System.out.print("Your grade letter is B+. "); else if(grade>=83 && grade<87) System.out.print("Your grade letter is B. "); else if(grade>=80 && grade<83) System.out.print("Your grade letter is B-. ");

else if(grade>=73 && grade<80) System.out.print("Your grade letter is C+. "); else if(grade>=70 && grade<73) System.out.print("Your grade letter is C. ");

else if(grade>=60 && grade<70) System.out.print("Your grade letter is D. ");

else if(grade<60) System.out.print("Your grade is F. You are failed. "); } } }

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!