So what i have to do is
Write a grading program for a class of students that has the following grading policies:
1. There are two quizzes, each with a maximum of 25 points;
2. There is one midterm exam, each with a maximum of 50 points;
3. There is one final exam, each with a maximum of 100 points.
Define and use a C++ structurefor the student record: Heres what i did
Okay, now User will enter values for following data items:Code:struct studentRecord { int studentID; string first_name; string last_name; int quiz1; int quiz2; int midTerm; int finalExam; double totalPoints; double percentTotal; char letterGrade; };
1)Student’s ID number
2)Student’s first name
3)Student’s last name
4)Quiz #1 score
5)Quiz #2 score
6)Midterm exam score
7)Final exam score
So i did this,
For Processing this i have toCode:void get_data(studentRecord& the_student) { //Check student ID cout << "\nEnter Student Id\n"; cin >> the_student.studentID; //Check for mistakes // Correct Value does this if ((the_student.studentID> 1) || (the_student.studentID < 99999)) { } // Incorrect does this // A loop To validate the Student ID while ((the_student.studentID < 1) || (the_student.studentID > 99999)) { cout <<"\nMust enter an Student ID between 1 and 99999.\n"; cout <<"Re Enter Student ID:\n"; cin >> the_student.studentID; cout <<"\n"; } //Get First and last names cout << "\nEnter First name\n"; cin >> the_student.first_name; cout << "\nEnter last name\n"; cin >> the_student.last_name; //Check Quiz 1 score cout << "\nEnter quiz 1 score\n"; cin >> the_student.quiz1; //Check for mistakes // Correct Value does this if ((the_student.quiz1> 0) || (the_student.quiz1 < 25)) { } // Incorrect does this // A loop To validate the quiz1 while ((the_student.quiz1 < 0) || (the_student.quiz1 > 25)) { cout <<"\nMust enter an quiz1 score between 0 and 25.\n"; cout <<"Re Enter quiz1 score:\n"; cin >> the_student.quiz1; cout <<"\n"; } //Check Quiz 2 score cout << "\nEnter quiz 2 score\n"; cin >> the_student.quiz2; //Check for mistakes // Correct Value does this if ((the_student.quiz2> 0) || (the_student.quiz2 < 25)) { } // Incorrect does this // A loop To validate the quiz2 while ((the_student.quiz2 < 0) || (the_student.quiz2 > 25)) { cout <<"\nMust enter an quiz2 score between 0 and 25.\n"; cout <<"Re Enter quiz2 score:\n"; cin >> the_student.quiz2; cout <<"\n"; } //Check Midterm cout << "\nEnter Mid Term score\n"; cin >> the_student.midTerm; //Check for mistakes // Correct Value does this if ((the_student.midTerm> 0) || (the_student.midTerm < 50)) { } // Incorrect does this // A loop To validate the midTerm while ((the_student.midTerm < 0) || (the_student.midTerm > 50)) { cout <<"\nMust enter an midTerm score between 0 and 50.\n"; cout <<"Re Enter a midTerm score:\n"; cin >> the_student.midTerm; cout <<"\n"; } //Check Final cout << "\nEnter Final Exam score\n"; cin >> the_student.finalExam; //Check for mistakes // Correct Value does this if ((the_student.finalExam> 0) || (the_student.finalExam < 100)) { } // Incorrect does this // A loop To validate the finalExam while ((the_student.finalExam < 0) || (the_student.finalExam > 100)) { cout <<"\nMust enter an finalExam score between 0 and 100.\n"; cout <<"Re Enter a finalExam score:\n"; cin >> the_student.finalExam; cout <<"\n"; } //Calculate Total Points // This adds together all quizes and exams the_student.totalPoints = the_student.quiz1 + the_student.quiz2 + the_student.midTerm + the_student.finalExam; //Calulate Percentage in class the_student.percentTotal = ((the_student.totalPoints * 100) / 200); //Figure out letter grade if (the_student.percentTotal>= 90) { the_student.letterGrade = 'A'; } else if ((the_student.percentTotal>= 80) || (the_student.percentTotal < 90)) { the_student.letterGrade = 'B'; } else if ((the_student.percentTotal>= 70) || (the_student.percentTotal < 80)) { the_student.letterGrade = 'C'; } else if ((the_student.percentTotal>= 60) || (the_student.percentTotal < 70)) { the_student.letterGrade = 'D'; } else if (the_student.percentTotal<60) { the_student.letterGrade = 'F'; } }
1)Use loops to check for a valid value for ID number and scores. (Which i think i did correctly)
2) Your program must continue to prompt the user until user enters a valid value for the data item being checked. (Which i also think i did.)
3) After a student’s input data has been validated, assign the data to appropriate member variables in the student record structure. (Which once again i think i did correctly.)
4) Process multiple records: There are several students in the class. Therefore, your program must prompt keyboard operator to determine whether there is another student to be processed, if not, display results (see output section below) and terminate program; otherwise, prompt user and accept input data for next student. The keyboard entry character “y” or “Y” indicates that there is another student to be processed; any other character indicates that there are no additional students to be processed. (I really need help with this one.)
5) For each student processed, calculate the following values, and assign the results to the appropriate member variable in the student record structure:
Student’s total points
Student’s percentage of total possible points (rounded to one decimal place)Code://Calculate Total Points // This adds together all quizes and exams the_student.totalPoints = the_student.quiz1 + the_student.quiz2 + the_student.midTerm + the_student.finalExam;
Now for the output, after each student their info is displayed.Code:int main() { studentRecord student; get_data(student); //Show to first decimal place. cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(1);
I have this under: int main()
Now here is where i really had trouble; After all students have been processed, display the following information:Code://Display Student Info cout << "\nStudent ID = " << student.studentID <<""; cout << "\nFirst Name = " << student.first_name <<""; cout << "\nLast Name = " << student.last_name <<""; cout << "\nQuiz 1 Score = " << student.quiz1 <<""; cout << "\nQuiz 2 Score = " << student.quiz2 <<""; cout << "\nMid Term Score = " << student.midTerm <<""; cout << "\nFinal Exam Score = " << student.finalExam <<""; cout << "\nTotal Points = " << student.totalPoints <<""; cout << "\nPercent Total = " << student.percentTotal <<"%"; cout << "\nLetter Grade = " << student.letterGrade <<"\n";
Total number of students processed
Highest total points achieved
Lowest total points achieved
Average total points achieved
Average letter grade achieved
Now heres my thinking on these, but i dont know how to implment
1) For the total numbers of students, just have a variable inside a loop increment every time the loop restarts.
2) For the highest and lowest points, use an if statement to determine whether or not the total points is higher or lower than the previous one and store the new value it if it is.
3) For the average, just keep adding the total points every loop then divide it by the number of students.
Any help would be greatly appreciated! I'm just a few weeks into coding, so im not all that good yet! But im certainly trying to learn.



LinkBack URL
About LinkBacks



