Back to Examples
package edu.iuk.GradebookClass;

import java.util.Scanner;

public class useGradebook {

  public static void main(String[] args) {

    // Jacob Morris
    // GradeBook

    // declare variables
    int userChoice = 0;
    String newGradeBook;
    GradeBook Java = new GradeBook("Java");
    System.out.println("Choose from the following options:\n\n 1- Create default Java gradebook:\n 2- Create a new gradebook:" + "\n 3- Display the welcome message:\n 4- Calculate the class average and the maximum grade:\n 5- Quit:");

    while (!(userChoice == 5)) {

      Scanner user = new Scanner(System.in);
      System.out.println("Enter your choice:");
      userChoice = user.nextInt();

      if (userChoice == 1) {

        Java.setCourseName("Java");
        System.out.println("The GradeBook is now Java.");

      } else if (userChoice == 2) {

        Scanner gradeName = new Scanner(System.in);
        System.out.println("Please enter the name of the new Gradebook:");
        newGradeBook = gradeName.nextLine();
        GradeBook newGrades = new GradeBook(newGradeBook);
        Java.setCourseName(newGradeBook);
        System.out.println("The GradeBook is now " + newGradeBook);

      } else if (userChoice == 3) {

        Java.displayMessage();

      } else if (userChoice == 4) {

        Java.determineClassAverage();

      } else if (!(userChoice == 5)) {

        System.out.println("Please enter a valid number!");

      }

    }

  }

}
Back to Examples

Startup Discount
Small Business?
Contact us for an Enormous Discount!