Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Problem with Grading calculator in java program

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with Grading calculator in java program

    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
    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();
     
     
    	}
     
     
    }
    and my notepad is this:
    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


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Problem with Grading calculator in java program

    Your post was separated from the one that was a number of years old. Even though your problem may be related, it's better to start a "fresh" thread as old threads tend to be ignored as "dead" (they smell).

    And welcome to the forum! Thanks for taking the time to learn how to post code correctly. If you haven't already, please read this topic to learn other useful info for new members.

    You're doing too much in the main() method. Have you learned how to use other methods yet? If so, break the main() method into smaller methods. If not, oh well.

    This is a good post, you've done most everything right, but can you point to where the problem is or what you need help with? I get the requirement, but I don't understand what help you need to program to it. Including the output of a sample run (or desired run) is a good thing, but without some explanation, we have to guess what it means. For example, what are the two lines after the student's name?

Similar Threads

  1. Grading System Program
    By jakeburns in forum What's Wrong With My Code?
    Replies: 9
    Last Post: August 24th, 2014, 09:02 PM
  2. grading system calculator
    By javacodeaddict in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 14th, 2014, 11:14 AM
  3. [SOLVED] Grading Program
    By greg2186 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: September 6th, 2012, 10:36 AM
  4. grading program help
    By devilhanzou in forum What's Wrong With My Code?
    Replies: 6
    Last Post: February 14th, 2011, 09:01 AM
  5. [SOLVED] Problem with Grading calculator in java program
    By Peetah05 in forum What's Wrong With My Code?
    Replies: 23
    Last Post: March 28th, 2009, 04:25 PM