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