Thread: Please Help Grade Curving program!!!

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    3

    Please Help Grade Curving program!!!

    I am coming from java programing and I really do not have a clue what I am doing in C++. If someone can please help me I would greatly appreciate it. I have included the code below, there are nine things that I am missing. someone please help me.





    Code:
    
    
    void processGrades(istream &in, ostream &out);
    
    
    
    
    
    int main()
    {
    	processGrades(cin, cout);
    
    	return 0;
    }
    
    
    void processGrades(istream &in, ostream &out)
    {
    	char choice = ' ';
    	int studentGrade = 0;
    	int curvedGrade;
    	double shift;
    	double curve;
    	double average;
    
    	//loop until they select quiz
    	while (choice != '4')
    	{
    		//print a menu
    		out << "\n\nChoose a type of curve:\n"
    				<< "1. Shift Curve\n"
    				<< "2. Krider Curve\n"
    				<< "3. Center Curve\n"
    				<< "4. Quit" << endl;
    
    		in >> choice; //read menu option (1, 2, 3, 4)
    
    		//don't do anything if Quit was chosen
    		//if the user entered a bad selection, it will skip this and just
    		//print the menu again.
    		if (choice >= '1' && choice <= '3')
    		{
    			shift = 0;
    			curve = 0;
    			average = 0;
    
    			//read the values to be used with that curve picked
    			if (choice == '1' || choice == '2')
    			{
    				//both shift and Krider curves need a shift value
    				shift = readShift(in, out);
    			}
    
    			if (choice == '2' || choice == '3')
    			{
    				//both Krider and center curves need a curve value
    				curve = readCurve(in, out);
    			}
    
    			if (choice == '3')
    			{
    				//the center curves need a class average
    				average = readAverage(in, out);
    			}
    
    
    
    			//read in a value before we start processing
    			studentGrade = readStudentGrade(in, out);
    
    			while (studentGrade >= 0)
    			{
    				//pick the type of curve that will be applied
    				switch (choice) {
    				case '1':
    					curvedGrade = shiftCurve(studentGrade, shift);
    					break;
    				case '2':
    					curvedGrade = kriderCurve(studentGrade, curve, shift);
    					break;
    				case '3':
    					curvedGrade = centerCurve(studentGrade, curve, average);
    					break;
    				}
    
    				//output the results
    				writeResult(out, studentGrade, curvedGrade);
    
    				//read in the next grade
    				studentGrade = readStudentGrade(in, out);
    			}
    		}
    
    
    	}
    }

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Which are those nine things you are missing?

  3. #3
    C++ Junkie Mozza314's Avatar
    Join Date
    Jan 2011
    Location
    Australia
    Posts
    174
    You need to either define or forward declare your functions before you use them. I'm not sure I remember correctly but I think Java lets you be lazy with this, so I can understand how it seems a bit foreign to you.

    For example on the line:

    Code:
    shift = readShift(in, out);
    "readShift" hasn't been defined. You need to forward declare beforehand like this:

    Code:
    double readShift(istream& in, ostream& out);

  4. #4
    Registered User
    Join Date
    Apr 2011
    Posts
    3
    --getValue
    Prompts a user to enter a value and then reads it in.
    The function should take (in this order) an istream, an ostream, and a string as parameters.
    Use the ostream variable to print the prompt contained in the string parameter.
    Use the istream variable to read in a double value.
    The function should return a double.
    Hint: istream and ostream must be passed by reference.
    --readStudentGrade
    The function prompts the user to enter a student grade and then reads in an int value.
    The function should take (in this order) an istream and an ostream.
    Use the ostream to print the prompt and the istream to read in an int value.
    The function should return an int representing the student's grade.
    --readShift, readCurve, readAverage
    These three functions are all very similar. They prompt the user to enter a value and then reads that value as a double.
    Each function should take (in this order) an istream and an ostream.
    readShift should prompt the user to enter the amount to shift the grades.
    readCurve should prompt the user for the amount of the curve (a number between 0 and 1 where 0 is no curve and 1 curves everyone to 100).
    readAverage prompts the user to enter the class average on this assignment.
    You should use getValue as part of your implementation of these functions.
    --shiftCurve
    This function takes (in order) an int representing the student's grade and a double representing the amount to shift the grade.
    The function returns an int representing the curved grade.
    The result of the expression should be cast to an int.
    Examples:
    If the grade is 76 and the shift is 5.0, then the curved score is 81.
    If the grade is 65 and the shift is 4.75, the curved score is 69.
    --kriderCurve
    This function takes (in order) an int representing the student's grade and a double representing the amount of the curve, and a double representing the amount to shift the grade.
    The function returns an int representing the curved grade.
    The result of the expression should be cast to an int.
    Calculation: To calculate the new grade, use the following formula. (Note that this is not in a form suitable to C++.)
    new grade = old grade + 100 curve * (1 - old grade / 100 ) + shift
    Examples:
    If the grade is 76, the curve is 0.25, and the shift is 5.0, then the curved score is 87.
    If the grade is 65, the curve is 0.1, and the shift is 4.75, the curved score is 73.
    --centerCurve
    This function takes (in order) an int representing the student's grade and a double representing the amount of the curve, and a double representing the average of the class.
    The function returns an int representing the curved grade.
    The result of the expression should be cast to an int.
    Calculation: To calculate the new grade, use the following formula. (Note that this is not in a form suitable to C++.)
    new grade = old grade + 15 curve * (1 - | average - old grade | / 100 ) **Updated ** changed score to old grade **
    Note: The expression | a | indicates the absolute value of a. So, in this formula, you will need to calculate the absolute value of average - score.
    Hint: The book mentions a function to find the absolute value of a number. Be sure to include the appropriate header so that you can use the function.
    Examples:
    If the grade is 76, the curve is 0.25 and the average is 75, then the curved score is 79.
    If the grade is 65 the curve is 0.1 and the average is 50, the curved score is 66.
    If the grade is 54 the curve is 0.6 and the average is 63, the curved score is 62.
    If the grade is 66 the curve is 0.6 and the average is 63, the curved score is 74.
    --writeResult
    This function takes an ostream, an int representing the student's current grade and an int representing the students new, curved grade.
    It does not return a value.
    In the function, print a message that states the old and new grades.
    Place a line feed at the end.
    Format the values so that the numbers are right aligned and have a width of 6.

    These are the nine things that i need. I had an exam today and the last 4 problems we had to write functions like this program and i didnt do to hot ...so hopefully after this i can understand this more. and yes Mozza314 i thinks that want i need i remember him talkin about it in class but when i do it by myself i just forget everything.

    getValue


    readStudentGrade

    readShift, readCurve, readAverage

    shiftCurve

    kriderCurve

    centerCurve

    writeResult
    Last edited by phil12; 04-07-2011 at 03:57 PM.

  5. #5
    C++ Junkie Mozza314's Avatar
    Join Date
    Jan 2011
    Location
    Australia
    Posts
    174
    Please don't just tell us what you're supposed to do and ask us to do it for you. Instead, ask specific questions relating to your difficulties with those tasks. See the homework policy.

    For example, what is it that troubles you about writing getValue? Have you attempted it? Do you at least know how to write it without the body, e.g.

    Code:
    void Foo()
    {
        // not implemented yet
    }

  6. #6
    Registered User
    Join Date
    Apr 2011
    Posts
    3
    oh im sorry. yes ill jus try to work it then

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Free program I'm sharing: ConvertEnumToStrings
    By Programmer_P in forum Projects and Job Recruitment
    Replies: 101
    Last Post: 07-18-2010, 12:55 AM
  2. Invalid Output of Minimum and Maximum Value in Array
    By georgio777 in forum C Programming
    Replies: 10
    Last Post: 09-19-2009, 03:17 AM
  3. Replies: 2
    Last Post: 09-16-2009, 06:00 AM
  4. c program help
    By Sleepwalker817 in forum C Programming
    Replies: 4
    Last Post: 03-29-2008, 05:31 AM
  5. Grade distribution program
    By MyTeachersANazi in forum C++ Programming
    Replies: 4
    Last Post: 03-26-2003, 09:54 PM