import java.util.Scanner; //for the ability to get input from
//the keyboard
import java.text.DecimalFormat;
public class Project3
{
public static void main(String[] args)
{
//enter variable below
double orgGrade = 0; //Variable for the Original Grade
double newGrade = 0; //Variable for the Grade after the Curve
double gradePercent = 0; //Variable for displaying the percentage from option 4.
double points = 10.0; //Variable for points added
double percent = .10; //Variable for given percentage
double gpoints = 0; //Variable for the Given points
double gpercent = 0; //Variable for the Given percentage
int a = 0; // Variable for Menu Selection
String Msg = "Press ENTER to return to the menu";
Scanner keyboard = new Scanner(System.in);
DecimalFormat df = new DecimalFormat("00.0");
//start program here
clearScreen();
orgGrade = orginalgrade(orgGrade); //get users grade.
clearScreen(); //clear the screen
a = menu(a, Msg); //show menu/selections
switch (a)
{
case 1:
addPoints(a, newGrade, orgGrade, points, Msg);
break;
case 2:
addPercent(a, newGrade, orgGrade, percent, gradePercent, Msg);
break;
case 3:
givenPoints(a, newGrade, orgGrade, gpoints, Msg);
break;
case 4:
givenPercent(a, newGrade, orgGrade, gpercent, Msg);
break;
case 5:
break;
}
}//end main
public static void clearScreen()
{
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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
}//end clearScreen
public static void freezeScreen()
{
Scanner keyboard = new Scanner(System.in);
System.out.print(" -- Press Enter to Continue --");
keyboard.nextLine();
}//end freezeScreen
public static void freezeScreen(String Msg)
{
Scanner keyboard = new Scanner(System.in);
System.out.print(Msg);
keyboard.nextLine();
}//end freezeScreen
public static double orginalgrade(double orgGrade)
{
Scanner keyboard = new Scanner(System.in);
System.out.print("What is the original grade? "); //Get original grade from user
orgGrade = keyboard.nextDouble();
return orgGrade;
}//end orgGrade
public static int menu(int a, String Msg)
{
Scanner keyboard = new Scanner(System.in);
System.out.println(" Grade Adjuster");
System.out.println(" by Aaron Webster "); // Greet user
System.out.println("******************************\n");
System.out.println("1. Curve by 10 points."); //menu options here
System.out.println("2. Curve by 10 percent.");
System.out.println("3. Curve by a certain number of points.");
System.out.println("4. Curve by a given percentage");
System.out.println("5. Exit program\n");
System.out.print("Enter your selection here: ");
a = keyboard.nextInt();
if (a > 5 || a < 1)
{
System.out.print("That is not a valid option!\n\n");
freezeScreen(Msg);
clearScreen();
menu(a, Msg);
return a;
}
return a;
}//end Menu
public static double addPoints(int a, double newGrade, double orgGrade, double points, String Msg)
{
newGrade = orgGrade + points;
System.out.println("Curve applied: " + points);
System.out.println("Adjusted grade: " + newGrade);
freezeScreen(Msg);
clearScreen();
menu(a, Msg);
return newGrade;
}//end addPoints
public static double addPercent(int a, double newGrade, double orgGrade, double percent, double gradePercent, String Msg)
{
newGrade = (orgGrade * percent) + orgGrade;
gradePercent = orgGrade * percent;
System.out.println("Curve applied: " + gradePercent);
System.out.println("Adjusted grade: " + newGrade);
freezeScreen(Msg);
clearScreen();
menu(a, Msg);
return newGrade;
}//end addPercent
public static double givenPoints(int a, double newGrade, double orgGrade, double gpoints, String Msg)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("How many points should be applied to curve the grade?");
gpoints = keyboard.nextDouble();
newGrade = gpoints + orgGrade;
if (newGrade > 100)
{
newGrade = 100;
}
System.out.println("Curve applied: " + gpoints);
System.out.println("Adjusted grade: " + newGrade);
freezeScreen(Msg);
clearScreen();
menu(a, Msg);
return newGrade;
}//end givenPoints
public static double givenPercent(int a, double newGrade, double orgGrade, double gpercent, String Msg)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter the percentage of the curve. (Ex. 10% would be .10)");
gpercent = keyboard.nextDouble();
newGrade = (gpercent * orgGrade) + orgGrade;
if (newGrade > 100)
{
newGrade = 100;
}
System.out.println("Curve applied: " + gpercent);
System.out.println("Adjusted grade: " + newGrade);
freezeScreen(Msg);
clearScreen();
menu(a, Msg);
return newGrade;
}//end givenPercent
}