Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

8. Explain the contact hypothesis.

Answered: 1 week ago

Question

2. Define the grand narrative.

Answered: 1 week ago