public class GradeCalculator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Is the final in the tests category (true/false)?");
boolean finalIsTest = sc.nextBoolean();
if (finalIsTest) {
System.out.println("What is your current grade?");
double grade = sc.nextDouble();
System.out.println("How much percent of your grade is the tests category?");
int testsPercent = sc.nextInt();
System.out.println("What is your current grade (in tests category)?");
double testsGrade = sc.nextDouble();
System.out.println("How many points is in the tests category currently?");
int testsPoints = sc.nextInt();
System.out.println("How many points is the final?");
int finalPoints = sc.nextInt();
System.out.println("What is your desired grade?");
double desiredGrade = sc.nextDouble();
double percentNeeded = desiredGrade - (grade - testsGrade * testsPercent/100.0);
double testPointsNeeded = (percentNeeded/testsPercent) * (testsPoints + finalPoints);
double finalPointsNeeded = testPointsNeeded - testsPoints;
System.out.println("You need a " + finalPointsNeeded + " on the final.");
} else {
System.out.println("What is your current grade?");
double grade = sc.nextDouble(); //wrapper class
System.out.println("How much percent of your grade is the final?");
int finalPercent = sc.nextInt();
System.out.println("What is your desired grade?");
double target = sc.nextDouble();
double percentNeeded = target - (grade/100.0)*(100.0-finalPercent);
double gradeNeeded = 100.0 * (percentNeeded/finalPercent);
System.out.println("You need a " + gradeNeeded + " on the test.");
}
}
}