Hello i have an other code that bother me because i am confused what i should do take a llok to the questions first:

**Example 2: The GradeBook Class:
Consider the attached GradeBook class. Complete the following tasks:
1-Modify the determineClassAverage method so it allows the user to enter the number of grades (i.e., the method no longer assumes 5 grades; this number needs to be determined by the user). Also this method needs to calculate and display the maximum grade.
2-Create a tester class named UseGradebook with a menu for the different items, and implement the menu items. Here’s a sample menu:
Choose from the following option:
1- Create the default Java GradeBook
2- Creat a new GradeBook
3- Dosplay the welcoming Message
4- Caluclate the class avarege and the Maxumim grade
5- quit

Enter your choise: **

That's the questions i tryed to start with JToption but i couldn't complete it and i know i should have the JOptionPane to do the menu or what!!??

Look to what i am doing i now i am not in the write trace but cold someone tell me from where i can start or what should i do

import java.util.*;
import javax.swing.*;

public class GradeBook {

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        System.out.println(" Enter the number of Students: ");
        int numberOfScore = in.nextInt();
        int[] scores = new int[5];

        System.out.print(" Enter " + numberOfScore + " scores: ") ;
        scores[0] = in.nextInt();
        scores[1] = in.nextInt();
        scores[2] = in.nextInt();
        scores[3] = in.nextInt();
        scores[4] = in.nextInt();
        displayGrades(scores);

    }
    public static void displayGrades(int[] grades){
        int highScore = bestGrade(grades);
        for (int i = 0; i < grades.length; i++){
            System.out.printf(" Student %d scor is %d and grade is %s%n", i, grades[i], assignLetterGrade(grades[i], highScore));
        }
    }
    private static Object assignLetterGrade(int grades, int highScore) {
        if (highScore - grades <= 10)
            return "A";
        return null;
    }
    private static int bestGrade(int[] grades) {
        // TODO Auto-generated method stub
        return 0;
    }

    }

It sounds to me like you are expected to produce a simple text menu on the console - not a GUI. So JOptionPane etc is not relevant here.

Just print out the text as shown in the "sample menu" you were given, and read the user's reply into an int variable. Use if tests or a switch to call the appropriate code for values 1, 2, 3 etc

Oh i am really stuck look to what i did; it desplay the munew but the user cannot choose anything):

import java.util.*;
import javax.swing.*;

public class GradeBook {
    private Random randomGen = new Random();
    private int user;
    private int grades;

    public char  determineClassAverage(){
    Scanner input = new Scanner(System.in);
    int user = randomGen.nextInt(5);
    System.out.println(" \nEnter the number of grades: ");  
    if ( grades >= 90 ){
        return 'A';
    }else if (grades >= 80){
        return 'B';
    }else if (grades >= 70){
        return 'C';
    }else if (grades >= 60){
        return 'D';
    }else {
        return 'F';
    }
    }

}

import java.util.Scanner;

public class UseGradeBook {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println(" \nChoose from the following options: ");
        System.out.println(" \n1- Create the default Java GradeBook: ");
        System.out.println(" \n2- Creat a new GradeBook: ");
        System.out.println(" \n3- Dosplay the welcoming Message: ");
        System.out.println(" \n4- Caluclate the class avarege and the Maxumim grade: ");
        System.out.println(" \n5- quit: ");
        System.out.println(" \nEnter your choise:  ");
        }

    }

You forgot

read the user's reply into an int variable.

(use your Scanner)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.