Question: I'm trying to instead of inputting a numeric value, I instead input the letter grade with corresponding -/+ signs and output the numeric value. Example:

I'm trying to instead of inputting a numeric value, I instead input the letter grade with corresponding -/+ signs and output the numeric value.

Example: input: C-, output: 1.7

import java.util.Scanner;

public class Grade { public static void main(String[] args) { Scanner in = new Scanner(System.in); double mark = in.nextDouble(); in.close();

String grade = null;

if (mark < 0 || mark > 4) { System.out.println("Mark is outside the boundaries!"); return; } else if (mark >= 3.85) { grade = "A"; } else if (mark >= 3.7) { grade = "A-"; } else if (mark >= 3.0) { grade = "B+"; } else if (mark >= 2.85) { grade = "B"; } else if (mark >= 2.7) { grade = "B-"; } else if (mark >= 2.0) { grade = "C+"; } else if (mark >= 1.85) { grade = "C"; } else if (mark >= 1.7) { grade = "C-"; } else if (mark >= 1.0) { grade = "D+"; } else if (mark > 0.85) { grade = "D"; } else if (mark > 0.7) { grade = "D-"; } else { grade = "F"; }

System.out.printf("Grade of student is %s", grade);

in.close(); } }

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!