I'm supposed to ask the user for a grade and store that grade for future use and add curves. How do I store the grade and send it to the different methods in the switch statement?
Thank you for checking out my question!

import java.util.Scanner; // Used for keyboard input

public class Project3 // Begin Class
{
public static void main(String[] args)
{

    int menu = 0;


    getGrade();


    displayMenu();
    switch (menu)
    {
        case 1:
            caseOne();
            break;
        case 2:
            caseTwo();
            break;
        case 3:
            caseThree();
    }


} // end main
public static double getGrade()
{
    double grade;
    Scanner keyboard = new Scanner(System.in);

    System.out.print("Please enter the original grade: ");
    grade = keyboard.nextDouble();
    return grade;

}
public void setGrade(double newGrade)
{
        double grade = newGrade;
}
public static int displayMenu()
{
    Scanner keyboard = new Scanner(System.in);
    int choice;

    System.out.println("        Grade Adjuster");
    System.out.println("      by Richard Nguyen ");
    System.out.println("********************************");

    System.out.println("\n\n");

    System.out.println("  1. Curve by 10 points"); // Add 10 points
    System.out.println("  2. Curve by 10 percent"); // Add 10 percent
    System.out.println("  3. Curve by a given number of points"); // Add a given number of points
    System.out.println("  4. Curve by a given percentage"); // Add by a given percentage
    System.out.println("  5. Quit"); // Force quit

    System.out.println("\n\n");

    System.out.print("Enter your selection: ");
    choice = keyboard.nextInt();
    return choice;
}

public static double caseOne()
{
    double curve = 10.0, 
           grade = 0,
           avg;


    System.out.println("Curve applied: " + curve + " points");
    avg = grade + curve;
    System.out.println("Adjusted grade: " + avg );
    return avg;                                             
}

public static void caseTwo()
{
    double points = 0, 
           grade = 0,
           avg = 0;
    points = grade * .10;
    grade = points + grade;
    System.out.println("Curve applied: " + points + " points");
    avg = grade + points;
    System.out.println("Adjusted grade: " + grade );

}
public static void caseThree()
{
    double grade = 0,
           points,
           avg;

    Scanner keyboard = new Scanner(System.in);
    System.out.println("How many points should be applied to curve the grade? ");
    points = keyboard.nextDouble();

    System.out.println("Curve applied: " + points + " points");
    avg = grade + points;
    System.out.println("Adjusted grade: " + grade );


}
public static void caseFour()
{
    double points = 0, 
           grade = 0,
           avg = 0;
    points = grade * .10;
    grade = points + grade;
    System.out.println("Curve applied: " + points + " points");
    avg = grade + points;
    System.out.println("Adjusted grade: " + grade );


}





public static void freezeScreen(String message)
{
    Scanner keyboard = new Scanner(System.in);

    System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
    keyboard.nextLine();

}

} // end class

You can store data in a class variable. After you have read in the user's input and verified that it is good, store it into a class variable to make it available to other methods in the class.
To pass the data to another class's method, you can call that method and pass it the data as a argument in the call:

refToAnotherClass.someMethod(theVarWithThedata);

It the method is in the same class you don't need refToAnotherClass.

That doesn't work for me. It keeps saying the variable is not declared. I'm trying to write this all in one class.

Please post the full text of the error message and the code that causes it.

My code was NOT something you could copy and paste into your program. It was only an example. You must replace the mehtod name and the argument's name with values from your program.

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.