/** This project is from the chapter 6 of the text book Programming Projects (Te
ID: 666949 • Letter: #
Question
/** This project is from the chapter 6 of the text book Programming Projects (Textbook - Page 272)
For full Grade: submit your code in text format (copy code and pate it in a Word doc), take a screenshot for the output of your program showing the list with 5 rows from 1 to 5 (students) with the 5 columns (grades).
Class grading program:
1. Write a grading program for a class with the following grading policies:
a. There are two quizzes, each graded on the basis of 10 points.
b. There is one midterm exam and one final exam, each graded on the basis of 100 points.
c. The final exam counts for 50% of the grade, the midterm counts for 25%, and the two quizzes together count for a total of 25%. (Do not forget to normalize the quiz scores. They should be converted to a percentage before they are averaged in.)
Any grade of 90 or more is an A, any grade of 80 or more (but less than 90) is a B, any grade of 70 or more (but less than 80) is a C, any grade of 60 or more (but less than 70) is a D, and any grade below 60 is an F. The program will read in the student’s scores and output the student’s record, which consists of two quiz and two exam scores as well as the student’s average numeric score for the entire course and final letter grade. Define and use a structure for the student record.
Hint:
Problem says this is for a class, rather than one student.
Strategy: Attack for a single student, then do for an array of N students.
The problem is
- Build: Debug in Grading (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -fexceptions -g -c C:UsersUnholymanDC3workspaceGradingmain.cpp -o objDebugmain.o
C:UsersUnholymanDC3workspaceGradingmain.cpp: In function 'int main()':
C:UsersUnholymanDC3workspaceGradingmain.cpp:46:5: error: 'StudentScoresandGrades' was not declared in this scope
C:UsersUnholymanDC3workspaceGradingmain.cpp:46:28: error: expected ';' before 'studentDetails'
C:UsersUnholymanDC3workspaceGradingmain.cpp:48:25: error: 'Student' was not declared in this scope
C:UsersUnholymanDC3workspaceGradingmain.cpp:49:27: error: 'studentDetails' was not declared in this scope
C:UsersUnholymanDC3workspaceGradingmain.cpp:49:50: error: 'getStudentDetails' was not declared in this scope
C:UsersUnholymanDC3workspaceGradingmain.cpp:50:25: error: 'Student' was not declared in this scope
C:UsersUnholymanDC3workspaceGradingmain.cpp:51:31: error: 'studentDetails' was not declared in this scope
C:UsersUnholymanDC3workspaceGradingmain.cpp:52:25: error: 'Student' was not declared in this scope
C:UsersUnholymanDC3workspaceGradingmain.cpp:53:9: error: 'display' was not declared in this scope
C:UsersUnholymanDC3workspaceGradingmain.cpp:53:17: error: expected ';' before 'StudentResult'
C:UsersUnholymanDC3workspaceGradingmain.cpp: At global scope:
C:UsersUnholymanDC3workspaceGradingmain.cpp:57:28: error: variable or field 'getStudentDetails' declared void
C:UsersUnholymanDC3workspaceGradingmain.cpp:57:28: error: 'StudentScoreandGrade' was not declared in this scope
C:UsersUnholymanDC3workspaceGradingmain.cpp:57:50: error: 'studentDetails' was not declared in this scope
C:UsersUnholymanDC3workspaceGradingmain.cpp:78:36: error: variable or field 'calculateStudentGrade' declared void
C:UsersUnholymanDC3workspaceGradingmain.cpp:78:36: error: 'StudentandGrade' was not declared in this scope
C:UsersUnholymanDC3workspaceGradingmain.cpp:78:53: error: 'studentDetails' was not declared in this scope
C:UsersUnholymanDC3workspaceGradingmain.cpp:131:1: error: expected declaration before '}' token
Process terminated with status 1 (0 minute(s), 0 second(s))
17 error(s), 0 warning(s) (0 minute(s), 0 second(s))
*/
#include <iostream>
using namespace std;
const int MAX_STUDENTS =6;
const double QUIZES_COUNT =.025; // 25%
const double MIDTERM_COUNTS =0.25; //25 %
const double FINAL_COUNTS = 0.50; // 50%
// Total of 100% (25% on quizes, 25% on midterm, and 50% on final)
//structure for a student record
struct StudentScoresandGrade
{
char studentFName;
double pointsInFirstQuiz;
double pointsInSecondQuiz;
double pointsInMidTermExam;
double pointsInFinalExam;
double averageScore;
char studentGrade;
};
//Functions
void getstudentDetails(StudentScoresandGrade& studentDetails);
void calculateStudentGrade(StudentScoresandGrade& studentDetails);
void displayStudentResult(StudentScoreandGrade studentDetails);
//Main
int main()
{
StudentScoresandGrades studentDetails[MAX_STUDENTS];
for(int student= 0; Student <MAX_STUDENTS; student++)
getStudentDetails(studentDetails[student]);
for(int student= 0; Student <MAX_STUDENTS; student++)
calculateStudentGrade(studentDetails[student]);
for(int student= 0; Student <MAX_STUDENTS; student++)
display StudentResult(studentDetails[student]);
return 0;
}
void getStudentDetails(StudentScoreandGrade &studentDetails)
{
//prompt for student FName
cout <<"Enter The Students First Name";
cin StudentDetails.studentFName;
//prompt for students quiz points for quiz 1
cout <<"Enter the number of points in quiz 1(MaxPoints=10):";
cin>>studentDetails.pointsInFirstQuiz;
//second quiz now
cout <<"Enter the Number of points in quiz 2(MaxPoints= 10):";
cin>>studentDetails.pointsInSecondQuiz;
//prompt for Midterm now.
cout <<"Enter the number of points in the MidTerm Exam(MaxPoints =100):";
cin>>studentDetails.pointsInMidTermExam;
//Points in Final now.
cout <<"Enter the Number of points in the Final Exam (MaxPoints=100):";
cin>>studentDetails.pointsInFinalExam;
cout <<endl;
}
void calculateStudentGrade(StudentandGrade& studentDetails)
{
double totalOfQuizes;
double AverageOfQuizes;
double normalizedAverageOfQuizes;
double QuizesScore;
double midtermExamScore;
double finalExamScore;
// time to calculate and normalize the quizes
totalOfQuizes=studentDetails.pointsInFirstQuiz +studentDetailsInSecondQuiz;
AverageOfQuizes=totalOfQuizes /2.0;
normalizedAverageOfQuizes=AverageOfQuizes=AverageOfQuizes*10;
QuizesScore=
normalizedAverageOfQuizes*Quizes_COUNT;
midtermExamScore=
studentDetails.pointsInMidTermExam*MIDTERM_COUNTS;
finalExamScore=
studentDetails.pointsInFinalExam*FINAL_COUNTS;
studentDetails.averageScore=
quizesScore + midtermExamScore +finalExamScore;
Finding the letter grade.
if(studentDetails.averageScore>=90)
studentDetails.studentGrade='A';
else if(studentDetails.averageScore>=80)
studentDetails.studentGrade='B';
else if(studentDetails.averageScore>=70)
studentDetails.studentGrade='C';
else if(studentDetails.averageScore>=60)
studentDetails.studentGrade='D';
else
studentDetails.studentGrade='F';
}
void displayStudentResult(const StudentScoresandGrade studentDetails)
{
// display details grades students first name,points on quizes, Midterm Exam and Final exam.
cout <<"The Students Name: "<<studentDetails.studentFName <<endl;
cout<<"The Points in the First Quiz: "<<studentDetails.pointsInFirstQuiz <<endl;
cout <<" The Points in the Second Quiz: "<<studentDetails.pointsInSecondQuiz <<endl;
cout <<" The Points in the MidTerm Exam: "<<studentDetails.pointsInMidTermExam <<endl;
cout <<" The Points in the Final Exam: "<<studentDetails.pointsInFinalExam<<endl;
cout <<"The Grade of this Student is :"<<studentDetails.studentGrade<<endl;
}
};
Explanation / Answer
Ans:
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
class Student{
public:
void averageGrade();
int ID;
string firstName;
string lastName;
double quiz1;
double quiz2;
double midterm;
double final;
};
double calcQuiz(int q1, int q2);
double calcMidFin(int mid, int fin);
void letterGrade(int finGrade);
int main(){
Student info, grade;
cout << "Please Enter Your Student ID:";
cin >> info.ID;
cout << "Please Enter Your First Name:";
cin >> info.firstName;
cout << "Please Enter Your Last Name:";
cin >> info.lastName;
do{
cout << "Please Enter Your Grade for Quiz 1 and 2 (Out of 10 Points for Each Quiz):" << endl;
cin >> grade.quiz1 >> grade.quiz2;
}while(grade.quiz1 > 10 && grade.quiz2 > 10); //Asks the user to input grade again if their input is over 10
cout << "Please Enter Your Grade for Midterm (Out of 100):" << endl;
cin >> grade.midterm;
cout << "Please Enter Your Grade for Final Exam (Out of 100):" << endl;
cin >> grade.final;
calcQuiz(grade.quiz1,grade.quiz2);
int finalQuiz = calcQuiz;
calcMidFin(grade.midterm,grade.final);
int totalMidFin = calcMidFin;
int gradeAverage = finalQuiz + totalMidFin;
int finalGrade = gradeAverage*100
letterGrade(finalGrade);
cout << "Your Student Information is:" << endl
cout << info.ID << endl;
cout << info.firstName << " " << info.lastName << endl;
cout << "Quiz 1: " << grade.quiz1 << endl;
cout << "Quiz 2: " << grade.quiz2 << endl;
cout << "Midterm: " << grade.midterm << endl;
cout << "Final: " << grade.final << endl;
cout << "Your Numerical Grade Is: " << finalGrade << endl;
cout << "Your Letter Grade Is: " << letterGrade << endl;
return 0;
}
double calcQuiz(int q1, int q2){
int newQuiz1 = q1*10; //Convert the quizes so they are out of 100 points
int newQuiz2 = q2*10;
int sum = newQuiz1 + newQuiz2; //Takes the average of both quizes
int quizAverage = sum/2;
double finalQuiz = quizAverage*0.25;
return finalQuiz;
}
double calcMidFin(int mid, int fin){
double midGrade = mid*0.25;
double finGrade = fin*0.5;
int midfin = midGrade + finGrade;
return midfin;
}
void letterGrade(int finGrade){ //Determines Letter Grade
if(finGrade>=90)
cout << "A";
else if(finGrade>=80 && finGrade<90)
cout << "B";
else if(finGrade>=70 && finGrade<80)
cout << "C";
else if(finGrade>=60 && finGrade<70)
cout << "D";
else if(finGrade<60)
cout << "F";
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.