Write a Java program that takes the marks (an integer) from the user and display
ID: 3905575 • Letter: W
Question
Write a Java program that takes the marks (an integer) from the user and display the relevant grade for that marks according to the following ranges.
Your program needs to have a separate method called findGrade which takes the marks as the input value and return the relevant grade.
Marks Range Grade 80 S Marks 75 S MarksExplanation / Answer
import java.util.Scanner; public class ConvertToGrade { static char findGrade(int marks) { if(marks >= 80) { return 'A'; } else if(marks >= 75) { return 'B'; } else if(marks >= 60) { return 'C'; } else { return 'D'; } } public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter marks: "); int marks = in.nextInt(); System.out.println("Grade is " + findGrade(marks)); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.