Thread: Please Help Grade Curving program!!!

1. 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. Which are those nine things you are missing?

3. 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. --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

5. 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. oh im sorry. yes ill jus try to work it then

Popular pages Recent additions