i have a similar problem but what i need to do is to detect an exused absent of which in my notepad is represented by 00 and 0 being an unexcused absent, anyway if a student has an excused absent example a quiz for that day will be deducted from the total quizzes example if i was the teacher and had 2 quizzes of 10 items each and she was absent in one of the quizes instead of let say her score was 9 on the first quiz it should go 9/10 and if it was an unexcused absent 9+0/20 anyway this is my java code and notepad example
and my notepad is this:import java.io.*; import java.util.*; import java.lang.*; public class GradingSystem { public static void main (String[] args) throws FileNotFoundException { System.out.println("** *** ** "); System.out.println(" ** ** ** ** "); System.out.println(" ** ** ** ** "); System.out.println(" ** ** ** ** "); System.out.println(" *** *** "); String firstName; String lastName; int NumberOfQuizzes; int QuizItems; double TotalQuizScore=0; double grade=0; double TotalQuizeGrade = 0; int NumberofActivities=0; int ActivityItems=0; int TotalActivityScore=0; double activity; double TotalActivityGrade; int NumberOfProjects=0; int ProjectItems=0; int TotalProjectScore=0; double project=0; double TotalProjectGrade=0; int NumberOfAttendance = 1; int AttendanceItems=0; int TotalAttendanceScore=0; double Attendance=0; double TotalAttendanceGrade=0; // Variables for calculation the Midterms and Final Grades int MidtermsFinalsItems = 0; int TotalMidtermsAndFinalsScore = 0; int NumberOfMidtermsFinals = 2; double MidtermsFinals = 0; double MidtermsFinalsGrade=0; int Midterms =0; int Finals =0; double WeightedScore = 0; double EquivalentScore = 0; String discard; double QPercentValue =0; double APercentValue=0; double PPercentValue=0; double AttendPercentValue=0; double MFttendPercentValue=0; int TotalPercentageInput=0 ; double TotalPercentageQuiz=0; double TotalPercentageActivity=0; double TotalPercentageProject=0; double TotalPercentageAttendance=0; double TotalPercentageMIdFinal =0; Scanner console = new Scanner(System.in); // This will calculate the equevalent score example 1.0, 1.5 etc. System.out.println("Enter Percentage for each Category all should sum to 100%"); do { System.out.print("Enter Percentage for quiz: "); TotalPercentageQuiz = console.nextDouble(); TotalPercentageInput +=TotalPercentageQuiz; QPercentValue=(TotalPercentageQuiz/100); System.out.print("Enter Percentage for Activity: "); TotalPercentageActivity = console.nextDouble(); TotalPercentageInput +=TotalPercentageActivity; APercentValue=(TotalPercentageActivity/100); System.out.print("Enter Percentage for Project: "); TotalPercentageProject = console.nextDouble(); TotalPercentageInput +=TotalPercentageProject; PPercentValue=(TotalPercentageProject/100); System.out.print("Enter Percentage for Attendance: "); TotalPercentageAttendance = console.nextDouble(); TotalPercentageInput +=TotalPercentageAttendance; AttendPercentValue=(TotalPercentageAttendance/100); System.out.print("Enter Percentage for Midterms and Finals: "); TotalPercentageMIdFinal = console.nextDouble(); TotalPercentageInput +=TotalPercentageMIdFinal ; MFttendPercentValue=(TotalPercentageMIdFinal/100); if (TotalPercentageInput !=100){ System.out.println("You have not entered values that sum up to 100 try again"); TotalPercentageInput=0 ; } } while(TotalPercentageInput != 100); // will add up the number or quezzes and there perfect scores System.out.print("Enter Number of Quizzes given: "); NumberOfQuizzes = console.nextInt(); if (NumberOfQuizzes > 0){ for (int b = 1; b <= NumberOfQuizzes; b++) { System.out.println("Please enter the Perfect Score for each Quiz:"); System.out.print("Quiz "+b+": "); QuizItems = console.nextInt(); TotalQuizScore = TotalQuizScore + QuizItems; } } System.out.print("Enter Number of Activities: "); NumberofActivities = console.nextInt(); if (NumberofActivities > 0){ for (int c = 1; c <= NumberofActivities; c++) { System.out.println("Please enter the Perfect Score for each Quiz: "); System.out.print("Activity "+c+": "); ActivityItems = console.nextInt(); TotalActivityScore += ActivityItems; } } System.out.print("Enter Number of Projects: "); NumberOfProjects = console.nextInt(); if (NumberOfProjects > 0){ for (int b = 1; b <= NumberOfProjects; b++) { System.out.println("Please enter the Perfect Score for each Project:"); System.out.print("Project "+b+": "); ProjectItems = console.nextInt(); TotalProjectScore += ProjectItems; } } if (NumberOfAttendance > 0){ for (int b = 1; b <= NumberOfAttendance; b++) { System.out.print("Please enter the Perfect Score for your Attendance: "); AttendanceItems = console.nextInt(); TotalAttendanceScore += AttendanceItems; } } System.out.print("Enter Midterms Perfect Score: "); Midterms = console.nextInt(); System.out.print("Enter Finals Perfect Score: "); Finals = console.nextInt(); TotalMidtermsAndFinalsScore = Midterms + Finals; Scanner inFile = new Scanner(new FileReader("stData.txt")); PrintWriter outFile = new PrintWriter("stAverage.txt"); outFile.println("First Name Last Name Quizzes Activity Project Attendance Grade Weighted Score Equivalent"); while (inFile.hasNext()) { //////////////////////////////////////////////////////////////////////////////////////////////////////// double qsum=0; firstName = inFile.next(); lastName = inFile.next(); discard = inFile.nextLine(); // will calcutlate for the quize average for (int x = 1; x <= NumberOfQuizzes; x++) { if (inFile.nextInt() == 00){ System.out.print("Detected an Excuse letter on Quizzes for "+firstName+" "+lastName+" what will be his new total score: "); +++++++++++++++++++++++++++I dont know what to do here to make it work++++++++++++++++++++++++++++ } else { grade = inFile.nextDouble(); qsum += grade; } } discard = inFile.nextLine(); double asum=0; for (int a = 1; a <= NumberofActivities; a++) { activity = inFile.nextDouble(); asum += activity; } discard = inFile.nextLine(); double psum=0; for (int a = 1; a <= NumberOfProjects; a++) { project = inFile.nextDouble(); psum += project; } discard = inFile.nextLine(); double Attendancesum=0; for (int a = 1; a <= NumberOfAttendance; a++) { Attendance = inFile.nextDouble(); Attendancesum += Attendance; } // Reading from FileReader and adding sum of all midterm and final grades discard = inFile.nextLine(); double MidtermsFinalssum = 0; for (int a = 1; a <= NumberOfMidtermsFinals; a++) { MidtermsFinals = inFile.nextDouble(); MidtermsFinalssum += MidtermsFinals; } //Calculating the Equivalent Score TotalQuizeGrade = ((qsum/TotalQuizScore)*100)*QPercentValue; TotalActivityGrade = ((asum/TotalActivityScore)*100)*APercentValue; TotalProjectGrade = ((psum/TotalProjectScore)*100)*PPercentValue; TotalAttendanceGrade = ((Attendancesum/TotalAttendanceScore)*100)*AttendPercentValue; MidtermsFinalsGrade = ((MidtermsFinalssum/TotalMidtermsAndFinalsScore)*100)*MFttendPercentValue; WeightedScore = TotalQuizeGrade+TotalActivityGrade+TotalProjectGrade+TotalAttendanceGrade+MidtermsFinalsGrade; if (WeightedScore >=97 ) EquivalentScore = 1.00; else if (WeightedScore >=93 ) EquivalentScore = 1.25; else if (WeightedScore >=89 ) EquivalentScore = 1.50; else if (WeightedScore >=85 ) EquivalentScore = 1.75; else if (WeightedScore >=82 ) EquivalentScore = 2.0; else if (WeightedScore >=79 ) EquivalentScore = 2.25; else if (WeightedScore >=76 ) EquivalentScore = 2.50; else if (WeightedScore >=73 ) EquivalentScore = 2.75; else if (WeightedScore >=70 ) EquivalentScore = 3.00; else if (WeightedScore <70 ) EquivalentScore = 5.00; outFile.printf("%-12s %-12s %4.2f %-8s %4.2f %-8s %4.2f %-8s %4.2f %-8s %4.2f %-8s %4.2f %-8s %4.2f", firstName, lastName, TotalQuizeGrade, "",TotalActivityGrade,"", TotalProjectGrade,"",TotalAttendanceGrade,"",MidtermsFinalsGrade,"",WeightedScore,"",EquivalentScore ); outFile.println(); } outFile.close(); } }
Bruce Wayne
9 9 9 00 9
10 10 10 9 9
90
50
87 87
Diana Prince
9 9 9 0 9
10 10 10 9 9
90
50
87 87
Peter Parker
4 4 4 9 9
5 5 5 3 3
60
50
50 50
Clark Kent
5 5 5 9 7
3 2 5 8 9
40
40
40 80