❓ Help Can you create using java

This program calculates the letter grade based on a numerical score.

Requirements:

Create a class named GradeCalculator with the following methods:
calculateGrade(int score) : This method takes an integer score as input and returns
a character representing the letter grade.
getLetterGradeDescription(char grade) : This method takes a character grade as
input and returns a string describing the corresponding letter grade (e.g., "A:
Excellent").
Use appropriate data types for score and grade.
Use an Control Structure statement to determine the letter grade based on the following
criteria:
A: 90-100
B: 80-89
C: 70-79
D: 60-69
F: below 60
Use the getLetterGradeDescription method to display a detailed explanation of the
grade.
A: Excellent
B: Good
C: Average
D: Below Average
F: Failing
Create a class named GradeCalculatorRunner that has the main method and will use the
GradeCalculator class.
 
Sure, here is a Java implementation of the Grade Calculator program based on the requirements you provided:

Java:
public class GradeCalculator {

    public char calculateGrade(int score) {
        if (score >= 90 && score <= 100) {
            return 'A';
        } else if (score >= 80 && score <= 89) {
            return 'B';
        } else if (score >= 70 && score <= 79) {
            return 'C';
        } else if (score >= 60 && score <= 69) {
            return 'D';
        } else {
            return 'F';
        }
    }

    public String getLetterGradeDescription(char grade) {
        switch (grade) {
            case 'A':
                return "A: Excellent";
            case 'B':
                return "B: Good";
            case 'C':
                return "C: Average";
            case 'D':
                return "D: Below Average";
            case 'F':
                return "F: Failing";
            default:
                return "Invalid Grade";
        }
    }
}

Java:
public class GradeCalculatorRunner {

    public static void main(String[] args) {
        GradeCalculator calculator = new GradeCalculator();

        int score = 85;
        char grade = calculator.calculateGrade(score);
        String gradeDescription = calculator.getLetterGradeDescription(grade);

        System.out.println("Score: " + score);
        System.out.println("Grade: " + grade);
        System.out.println("Grade Description: " + gradeDescription);
    }
}

In this program, the GradeCalculator class contains methods to calculate the letter grade based on a numerical score and to get a description of the letter grade. The GradeCalculatorRunner class demonstrates the usage of the GradeCalculator class by calculating a grade for a given score and printing the result.

You can copy this code into your Java IDE, compile, and run it to see the output. Let me know if you need any further assistance or modifications.
 

About this Thread

  • 1
    Replies
  • 302
    Views
  • 1
    Participants
Last reply from:
Unknown user

Trending Topics

Online now

Members online
364
Guests online
1,070
Total visitors
1,434

Forum statistics

Threads
2,273,591
Posts
28,950,479
Members
1,235,846
Latest member
viscahm16
Back
Top