Variables and Data Types (1.2) Homework Hacks

Hack (Simple Grade Calculator)

import java.util.Scanner;

public class GradeCalculator {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.print("Enter your name: ");
        String name = scanner.nextLine();

        System.out.print("Enter the class name: ");
        String className = scanner.nextLine();

        System.out.print("Enter your first test score: ");
        double scoreOne = scanner.nextDouble();

        System.out.print("Enter your second test score: ");
        double scoreTwo = scanner.nextDouble();

        System.out.print("Enter your third test score: ");
        double scoreThree = scanner.nextDouble();

        double averageScore = (scoreOne + scoreTwo + scoreThree) / 3;

        if (averageScore >= 90) {
            System.out.println("A");
        } else if (averageScore >= 80) {
            System.out.println("B");
        } else if (averageScore >= 70) {
            System.out.println("C");
        } else if (averageScore >= 60) {
            System.out.println("D");
        } else {
            System.out.println("F");
        }

        scanner.close();
    }
}