Grade Calculator in Java: Explanation & Practice
Convert a score to a letter grade
Problem summary
Given a score of 85, output the corresponding letter grade (A>=90, B>=80, C>=70, D>=60, F<60).
Starter code
public class Main {
public static void main(String[] args) {
int score = 85;
// Determine grade based on score
// Print: Grade: <letter>
}
}Expected output and test cases
- Score 85 = Grade B
Grade: B
Hints
- Use if-else if-else chain for multiple conditions
- Check from highest to lowest (90, 80, 70, 60)
- The final else catches all scores below 60
Related Control Flow exercises
Practice all Control Flow exercises · Run this idea in the Java compiler