help me to write programm that use class Design a ProgrammingProject class that
ID: 3736976 • Letter: H
Question
help me to write programm that use class Design a ProgrammingProject class that is derived from the GradedActivity class presented in your book. The ProgrammingProject class should determine the grade a student receives on a programming project. The student's total scores can be up to 100, and is determined in the following manner Use of classes: 15 points Code Execution: 35 points Proper Choice of Code: 21 points Correct Pseudocode: 10 points Use of comments: 11 points Input/Output/professionalism: 8 points Your ProgrammingProject class should define these point categories as member variables. After entering the scores, a total should be returned, as well as the letter grade, which is obtained from the parent class, GradedActivity Make sure that your member data is protected (with low level validation that creates an Exit Failure when necessary) Validate user's input (high level validation) for all scores-0 so that your program doesn't cause an Exit_Failure down in the object. Create a user-interface program to demonstrate your class. Make your input and output professional. Break your code down into functions as necessary Programming Notes: The GradedActitivity class is in your book, in edition 9, it starts on page 909; in edition 8, it starts on page 893-4 The ProgrammingProject class is based on (inherits from) the GradedActivity The ProgrammingProject class will contain members for the scores and the associated mutator/accessor functions, BUT it will call the setScore function and the getLetterGrade function from GradedActivity The main program will prompt and input and do high-level validation and store the results and then create the output display This isn't a particularly taxing assignment, so spend some time really doing niceExplanation / Answer
ScreenShot
--------------------------------------------------------------------------------------------------------------------------------
Code:-
//Header files
#include<iostream>
#include<string>
//For I/O
using namespace std;
//Base class
class grade {
//Member varibles
private:
string sname, sId;
int pScore, cScore, mScore, eScore, comScore;
//member functions
public:
//set all values cominf from main(mutator)
void setName(string name) {
sname = name;
}
void setsId(string id ) {
sId =id;
}
void setpScore(int pmark) {
pScore = pmark;
}
void setcScore(int cmark) {
cScore = cmark;
}
void setmScore(int mmark) {
mScore = mmark;
}
void seteScore(int emark) {
eScore = emark;
}
void setcomScore(int commark) {
comScore = commark;
}
//Get all values of private variables(accessor)
string getsName() {
return sname;
}
string getsId() {
return sId;
}
int getpScore() {
return pScore;
}
int getcScore() {
return cScore;
}
int getmScore() {
return mScore;
}
int geteScore() {
return eScore;
}
int getcomScore() {
return comScore;
}
//Virtual function to get letter grade
virtual void getLetterGrade() {
}
};
//Derived class from grade
class gradeCalculation :public grade
{
public:
//Override the getLettrGrade() function of grade base class
void getLetterGrade() {
//Get Student name and ID
cout << endl << "Student Name = " << getsName();
cout << endl << "Student Id = " << getsId();
//Calculate total score
int total = getpScore() + getcScore() + getmScore() + geteScore() + getcomScore();
//display total score
cout << endl << "Your Total Score = " << total;
//calculate average
int avg = total / 5;
cout << endl << "Your Average Score = " << avg;
//Conditions for letter grading according to the average
if (avg > 90) {
cout << endl << "Your grade is A ."<<endl;
}
else if (avg > 80 && avg<=90) {
cout << endl << "Your grade is B ."<<endl;
}
else if (avg > 70 && avg <= 80) {
cout << endl << "Your grade is C ."<<endl;
}
else if (avg > 60 && avg <= 70) {
cout << endl << "Your grade is D ."<<endl;
}
else {
cout << endl << "Your grade is F ."<<endl;
}
}
};
//Main method
int main()
{
//variable declaration
string sname,sId;
int pScore, cScore, mScore, eScore, comScore;
//Prompt user for name
cout << "Please enter your name: ";
getline(cin, sname);
//prompt user for id and error check
cout << "Please yourId : ";
getline(cin, sId);
while (sId.length() > 6 || sId.length() <= 0) {
cout << endl << "Error!!!always enter ID greater thatn 0 and lessthan 6 in length";
cout << "Please yourId : ";
getline(cin, sId);
}
//prompt user for Scores and error check
cout <<endl<<"Please enter Physics score: ";
cin >> pScore;
while (pScore <= 0 && pScore<=100) {
cout << endl<<"Error!!!always enter score greater thatn 0";
cout << "Please enter Physics score: ";
cin >> pScore;
}
cout << "Please enter Chemistry score: ";
cin >> cScore;
while (cScore <= 0 && cScore <= 100) {
cout << endl << "Error!!!always enter score greater thatn 0";
cout << "Please enter Chemistry score: ";
cin >> cScore;
}
cout << "Please enter Mathematics score: ";
cin >> mScore;
while (mScore <= 0 && mScore <= 100) {
cout << endl << "Error!!!always enter score greater thatn 0";
cout << "Please enter Mathematics score: ";
cin >> mScore;
}
cout << "Please enter English score: ";
cin >> eScore;
while (eScore <= 0 && eScore <= 100) {
cout << endl << "Error!!!always enter score greater thatn 0";
cout << "Please enter English score: ";
cin >> eScore;
}
cout << "Please enter computer score: ";
cin >> comScore;
while (comScore <= 0 && comScore <= 100) {
cout << endl << "Error!!!always enter score greater thatn 0";
cout << "Please enter computer score: ";
cin >> comScore;
}
grade *gptr;
gradeCalculation gc;
gptr = &gc;
gptr->setName(sname);
gptr->setsId(sId);
gptr->setpScore(pScore);
gptr->setcScore(cScore);
gptr->setmScore(mScore);
gptr->seteScore(eScore);
gptr->setcomScore(comScore);
//virtual function, binded at runtime
gptr->getLetterGrade();
return 0;
}
-----------------------------------------------------------------------------------------
Note:-
As per my understanding, you want to calculate letter grade ,by calculating total and average score.
Display the letter grade and using inheritance and virtual function.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.