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

centralLinkl Central MicD Assignments-CFS 180 x D HW2-Gradeclassifier.pd1 , C Se

ID: 3881936 • Letter: C

Question

centralLinkl Central MicD Assignments-CFS 180 x D HW2-Gradeclassifier.pd1 , C Secure l https://blackboardcmích.edu/bbcswebdav/pid-5536689 p x chegg Study! Guided S X (- 439950/9 1/courses/CPS180-18500-22342/41/HW2-GradeClassifier.pdf Home| Central Michi Zy Central Michigan Ui Y Fantasy Reatll 21 C Home | Chogg.com omework ASSlgnmen GradeClassifier.java Due date: February 11th, 2018 Submission: submit GradeClassifier.java to Blackboard The main purpose of this assignment is to practice basic decision making in Java. Write a program to ask user for a number grade between 0 and 100. Convert it to letter grade based on the tollowing scheme: 0-60) 60 70 (70-80 c 80-90) 90-100] A If the number grade entered by the user is out of range (e.8., less than 0 or greater than 100), display a message to notice that the grade is invalid. Sample interaction: What is your score? 83 You will receive B What is 120 Oops, you entered an invalid gradel your score? Test your program with different numbers to make sure it runs correctly 12:42 PM O Type here to search

Explanation / Answer

Dear student;

copy the below code GradeClassifier.java file and run with different input to see valid input.

The program has inline comments to make you understandable each of the line please ask me any more explanation is required.

import java.util.Scanner;

public class GradeClassifier {

   public static void main(String args[]) throws Throwable {

       int score;

       System.out.print("What is your score?: "); // Printing Statement asking for user to input

       while (true)

           try {

               // Reading input from console and parsing it to integer if not parse to integer

               // throwing message to enter valid input

               score = Integer.parseInt(new Scanner(System.in).nextLine());

               String grade = "";

               if (score > 0 && score < 100) { // checking condition for valid grade

                   if (score < 60) { // deciding grages as per the requirement

                       grade = "E";

                   } else if (score > 60 && score < 70) {

                       grade = "D";

                   } else if (score > 70 && score < 80) {

                       grade = "C";

                   } else if (score > 80 && score < 90) {

                       grade = "B";

                   } else if (score > 90 && score < 100) {

                       grade = "A";

                   }

                   System.out.print("You will receive " + grade); // printing grade in console

               } else {

                   System.out.print("Oops, you entered an invalid grade! "); // invalid grade message

               }

           } catch (NumberFormatException exception) {

               System.out.print("Please enter valid score: "); // throwing error when user enter other than numbers

           }

   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote