Gradebook program


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Gradebook program

Hybrid View

  1. #1
    Join Date
    Oct 2006
    Posts
    2

    Gradebook program

    Hey everyone, I am having a bit of a problem with a program I have to write for class. I have to make a gradebook that determines students' elegibility for sports based on their grades and the number of classes they are taking. Our teacher gave us 6 different sets of letter grades. I have to code my program to output ineligible if they are taking less that 4 classes, have a GPA lower than a 2.0, and they cannot have an "F" in a class. Right now, I am working on the GPA portion of the assignment. I have inputted the 6 student's letter grades in constructers at the end of the program. I have been trying to tell java to make these chars equal to a double value so I can average them together to get the GPA. I keep on getting errors when I try and compile. I was wondering if anyone could look at the code and help me out a bit.

    Also, I have no idea how to add up the number of classes the student is taking. Once I figure this and the GPA portion, I can easily throw it into an if/else method and have it run.

    Thanks for your time!

    Code:
    class Gradebook
    {
    	private char c1;
    	private char c2;
    	private char c3;
    	private char c4;
    	private char c5;
    	private char c6;
    	private char c7;
    	private char A;
    	private char B;
    	private char C;
    	private char D;
    	private char F;
    
    	public Gradebook(char classOne, char classTwo, char classThree, char classFour, char classFive)
    	{
    		c1 = classOne;
    		c2 = classTwo;
    		c3 = classThree;
    		c4 = classFour;
    		c5 = classFive;
    
    		public void set(char A, double 4.0)
    		public void set(char B, double 3.0)
    		public void set(char C, double 2.0)
    		public void set(char D, double 1.0)
    		public void set(char F, double 0.0)
    		
    		public double getGPA()
    		{
    			return (c1 + c2 + c3 + c4 + c5)/2;
    		}
    	}
    	public Gradebook(char classOne, char classTwo, char classThree)
    	{
    		c1 = classOne;
    		c2 = classTwo;
    		c3 = classThree;
    	}
    	public Gradebook(char classOne, char classTwo, char classThree, char classFour, char classFive, char classSix)
    	{
    		c1 = classOne;
    		c2 = classTwo;
    		c3 = classThree;
    		c4 = classFour;
    		c5 = classFive;
    		c6 = classSix;
    	}
    	public Gradebook(char classOne, char classTwo, char classThree, char classFour, char classFive, char classSix, char classSeven)
    	{
    		c1 = classOne;
    		c2 = classTwo;
    		c3 = classThree;
    		c4 = classFour;
    		c5 = classFive;
    		c6 = classSix;
    		c7 = classSeven;
    	}
    	
    
    	public static void main(String[] args)
    	{
    		Gradebook grades = new Gradebook('B','B','C','B','F');
    		Gradebook grades2 = new Gradebook('C','D','C');
    		Gradebook grades3 = new Gradebook('A','B','A');
    		Gradebook grades4 = new Gradebook('C','B','D','D','D','C');
    		Gradebook grades5 = new Gradebook('A','A','B','A','A','B','A');
    		Gradebook grades6 = new Gradebook('C','D','F','F','D');
    	}
    }

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    Have you been given any other guidance about your program? Any mention about organizing your gradebook around students who are receiving a certain number and values of grades? Are each set of grades a set of grades for one class, or a set of grades for one student?

  3. #3
    Join Date
    Oct 2006
    Posts
    5
    Have you been given any other guidance about your program?
    yes, here

  4. #4
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    I was inquiring more about the statement of the problem, implementation parameters, and the desired solution from your instructor.

    The suggestions from people on the other site about changing the design of your gradebook to be student oriented are sound.

    Don't worry about "maps". You can have an array of students. The student class will hold the data fields which store how many classes he/she is taking and the grades which have been assigned.
    Last edited by nspils; 10-24-2006 at 08:43 AM.

  5. #5
    Join Date
    Oct 2006
    Posts
    2
    I finished the code and it works properly(about 250 lines >.<). Today we were going over strings and our teacher told us that we need to have the user input the letter grades into the program instead of putting the grades in the constructor. Now I am completely lost because I don't have a clue how to get the user input a character and have it store the values in Gradebook() as the constructors did in my comments at the bottom of the program. Any help would be much appreciated!

    Code:
    class Gradebook
    {
    	private char c1;
    	private char c2;
    	private char c3;
    	private char c4;
    	private char c5;
    	private char c6;
    	private char c7;
    	private double gpa;
    	private double g1;
    	private double g2;
    	private double g3;
    	private double g4;
    	private double g5;
    	private double g6;
    	private double g7;
    	private char fail;
    	private char grade;
    		
    	public double getValue(char grade) 
    	{
    	    switch (grade) 
    	    {
    	        case 'A':    return 4.0;
    	        case 'B':    return 3.0;
    	        case 'C':    return 2.0;
    	        case 'D':    return 1.0;
    	        case 'F':    return 0;
    	    }
    	    return 0;
    	}
    	
    		public Gradebook(char classOne)
    	{
    		c1 = classOne;
    
    		double g1 = getValue(c1);
    		
    		double gpa = (g1) / 1.0;
    		System.out.println("The student's GPA is : " + gpa);
    		if (gpa >= 2.0) {
    			System.out.println("     Ineligible-GPA lower than a 2.0");
    		}
    		
    		if (c1 == 'F') {
    			System.out.println("     Ineligible-Failed one or more classes");
    			System.out.println("     Ineligible-Needs to take a minimum of four classes-Taking one");
    		} 
    	}
    
    	public Gradebook(char classOne, char classTwo)
    	{
    		c1 = classOne;
    		c2 = classTwo;
    
    		double g1 = getValue(c1);
    		double g2 = getValue(c2);
    		
    		double gpa = (g1 + g2) / 2.0;
    		System.out.println("The student's GPA is : " + gpa);
    		System.out.println("     Ineligible-Not taking at least four classes");
    		if (gpa < 2.0) {
    			System.out.println("     Ineligible-GPA lower than a 2.0");
    		}
    		
    		if (c1 == 'F') {
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c2 == 'F') {
    			System.out.println("     Ineligible-Failed one or more classes");
    		}
    		
    	}
    
    	public Gradebook(char classOne, char classTwo, char classThree)
    	{
    		c1 = classOne;
    		c2 = classTwo;
    		c3 = classThree;
    
    		double g1 = getValue(c1);
    		double g2 = getValue(c2);
    		double g3 = getValue(c3);
    		
    		double gpa = (g1 + g2 + g3) / 3.0;
    		System.out.println("The student's GPA is : " + gpa);
    		System.out.println("     Ineligible-Not taking at least four classes");
    		if (gpa < 2.0) {
    			System.out.println("     Ineligible-GPA lower than a 2.0");
    		}
    		
    		if (c1 == 'F') {
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c2 == 'F') {
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c3 == 'F'){
    			System.out.println("     Ineligible-Failed one or more classes");
    		}
    		
    	}
    	
    		public Gradebook(char classOne, char classTwo, char classThree, char classFour)
    	{
    		c1 = classOne;
    		c2 = classTwo;
    		c3 = classThree;
    		c4 = classFour;
    		
    		double g1 = getValue(c1);
    		double g2 = getValue(c2);
    		double g3 = getValue(c3);
    		double g4 = getValue(c4);
    		
    		double gpa = (g1 + g2 + g3 + g4) / 4.0;
    		System.out.println("The student's GPA is : " + gpa);
    		if (gpa < 2.0) {
    			System.out.println("     Ineligible-GPA lower than a 2.0");
    		}
    		
    		if (c1 == 'F') {
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c2 == 'F') {
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c3 == 'F'){
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c4 == 'F'){
    			System.out.println("     Ineligible-Failed one or more classes");
    		}
    		
    		if (!(c1 == 'F') && !(c2 == 'F') && !(c3 == 'F') && !(c4 == 'F') && gpa >= 2.0){
    				System.out.println("     Eligible");
    			}			
    	}
    
    	public Gradebook(char classOne, char classTwo, char classThree, char classFour, char classFive)
    	{
    		c1 = classOne;
    		c2 = classTwo;
    		c3 = classThree;
    		c4 = classFour;
    		c5 = classFive;
    		
    		double g1 = getValue(c1);
    		double g2 = getValue(c2);
    		double g3 = getValue(c3);
    		double g4 = getValue(c4);
    		double g5 = getValue(c5);
    		
    		double gpa = (g1 + g2 + g3 + g4 + g5) / 5.0;
    		System.out.println("The student's GPA is : " + gpa);
    		if (gpa < 2.0) {
    			System.out.println("     Ineligible-GPA lower than a 2.0");
    		}
    		
    		if (c1 == 'F') {
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c2 == 'F') {
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c3 == 'F'){
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c4 == 'F'){
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c5 == 'F'){
    			System.out.println("     Ineligible-Failed one or more classes");
    		}
    		
    		if (!(c1 == 'F') && !(c2 == 'F') && !(c3 == 'F') && !(c4 == 'F') && !(c5 == 'F') && gpa >= 2.0){
    				System.out.println("     Eligible");
    			}			
    	}
    	
    	public Gradebook(char classOne, char classTwo, char classThree, char classFour, char classFive, char classSix)
    	{
    		c1 = classOne;
    		c2 = classTwo;
    		c3 = classThree;
    		c4 = classFour;
    		c5 = classFive;
    		c6 = classSix;
    		
    		double g1 = getValue(c1);
    		double g2 = getValue(c2);
    		double g3 = getValue(c3);
    		double g4 = getValue(c4);
    		double g5 = getValue(c5);
    		double g6 = getValue(c6);
    		
    		double gpa = (g1 + g2 + g3 + g4 + g5 + g6) / 6.0;
    		System.out.println("The student's GPA is : " + gpa);
    		if (gpa < 2.0) {
    			System.out.println("     Ineligible-GPA lower than a 2.0");
    		}
    		
    		if (c1 == 0.0) {
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c2 == 'F') {
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c3 == 'F'){
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c4 == 'F'){
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c5 == 'F'){
    			System.out.println("     Ineligible-Failed one or more classes");
    		} else if (c6 == 'F'){
    			System.out.println("     Ineligible-Failed one or more classes");
    		}
    		
    		if (!(c1 == 'F') && !(c2 == 'F') && !(c3 == 'F') && !(c4 == 'F') && !(c5 == 'F') && !(c6 == 'F') && gpa >= 2.0){
    				System.out.println("     Eligible");
    			}			
    	}
    	public Gradebook(char classOne, char classTwo, char classThree, char classFour, char classFive, char classSix, char classSeven)
    	{
    		c1 = classOne;
    		c2 = classTwo;
    		c3 = classThree;
    		c4 = classFour;
    		c5 = classFive;
    		c6 = classSix;
    		c7 = classSeven;
    		
    		double g1 = getValue(c1);
    		double g2 = getValue(c2);
    		double g3 = getValue(c3);
    		double g4 = getValue(c4);
    		double g5 = getValue(c5);
    		double g6 = getValue(c6);
    		double g7 = getValue(c7);
    		
    		double gpa = (g1 + g2 + g3 + g4 + g5 + g6 + g7) / 7.0;
    		System.out.println("The student's GPA is : " + gpa);
    			if (gpa < 2.0) {
    				System.out.println("     Ineligible-GPA lower than a 2.0");
    			}
    	
    			if (c1 == 'F') {
    				System.out.println("     Ineligible-Failed one or more classes");
    			} else if (c2 == 'F') {
    				System.out.println("     Ineligible-Failed one or more classes");
    			} else if (c3 == 'F'){
    				System.out.println("     Ineligible-Failed one or more classes");
    			} else if (c4 == 'F'){
    				System.out.println("     Ineligible-Failed one or more classes");
    			} else if (c5 == 'F'){
    				System.out.println("     Ineligible-Failed one or more classes");
    			} else if (c6 == 'F'){
    				System.out.println("     Ineligible-Failed one or more classes");
    			} else if (c7 == 'F'){
    				System.out.println("     Ineligible-Failed one or more classes");
    			}
    			
    		if (!(c1 == 'F') && !(c2 == 'F') && !(c3 == 'F') && !(c4 == 'F') && !(c5 == 'F') && !(c6 == 'F') && !(c7 == 'F') && gpa >= 2.0){
    				System.out.println("     Eligible");
    			}			
    	}
    
    	public static void main(String[] args)
    	{
                  System.out.println( "Type the letter grades for up to seven classes: " );
    
    			
    /*		Gradebook grades = new Gradebook('B','B','C','B','F');
    		Gradebook grades2 = new Gradebook('C','D','F');
    		Gradebook grades3 = new Gradebook('A','B','A');
    		Gradebook grades4 = new Gradebook('C','B','D','D','D','C');
    		Gradebook grades5 = new Gradebook('A','A','B','A','A','B','A');
    		Gradebook grades6 = new Gradebook('C','D','F','F','D');
    */
    	}
    }

  6. #6
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    What guidance have you been given about sending a message to the console, such as "Please enter a letter grade" and then assigning the response to a variable?

Similar Threads

  1. soft drink Vending machine program
    By divagoddess in forum C++
    Replies: 5
    Last Post: 08-14-2009, 04:12 PM
  2. Help with a program
    By stormswimmer in forum Java
    Replies: 2
    Last Post: 01-02-2006, 04:17 PM
  3. Please help with running executable vb program.
    By Gordon Reichhardt in forum VB Classic
    Replies: 2
    Last Post: 01-08-2002, 11:06 AM
  4. How can I build copy protection into my program
    By W.Pierce in forum VB Classic
    Replies: 1
    Last Post: 12-11-2001, 09:28 AM
  5. Replies: 0
    Last Post: 12-15-2000, 11:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center