FOR C++: Programming Requirements: Design a ProgrammingProject class that is der
ID: 3699072 • Letter: F
Question
FOR C++:
Programming Requirements:
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.
PLEASE SHOW PROGRAM WORKS WITH A PICTURE
Explanation / Answer
ScreenShot
-------------------------------------------------------------------------------------------------------------------
Program
//Header Files
#include<iostream>
#include<string>
//Name space for cin cout
using namespace std;
//Grade Activity class
class GradeActivity {
//Member variable
private:
double score;
//Member functions
public:
//default constructor
GradeActivity() {
score = 0.0;
}
//parameterised constructor
GradeActivity(double s) {
score = s;
}
//Mutator
void setScore(double s) {
score = s;
}
//Accessor
double getScore(){
return score;
}
//Grade generation function
char getLetterGrade() const;
};
//Grade generation function definition
char GradeActivity::getLetterGrade() const{
char letterGrade;
if (score > 89)
letterGrade = 'A';
else if (score > 79)
letterGrade = 'B';
else if (score > 69)
letterGrade = 'C';
else if (score > 59)
letterGrade = 'D';
else
letterGrade = 'F';
return letterGrade;
}
//programming Project class
class ProgrammingProject:public GradeActivity
{
//member variable
private:
int score1, score2, score3;
string name;
//Member functions
public:
//Default constructor
ProgrammingProject() {
name = "";
score1 = 0.0;
score2 = 0.0;
score3 = 0.0;
}
//Mutator
void setScore1(double s1) {
score1 = s1;
}
void setScore2(double s2) {
score2 = s2;
}
void setScore3(double s3) {
score3 = s3;
}
void setName(string n) {
name=n;
}
//accessor
double getScore1() {
return score1;
}
double getScore2() {
return score2;
}
double getScore3() {
return score3;
}
//member function to calculate total
double getTotal() const;
};
//calculate total function definition
double ProgrammingProject::getTotal() const{
double total=(score1+score2+score3)/3;
return total;
}
//main method
int main()
{
//Object creation
ProgrammingProject pp;
GradeActivity ga;
string name;
double score1, score2, score3;
cout << "please Enter The Student Name :";
getline(cin, name);
cout << "Please enter First Score:";
cin >> score1;
cout << "Please enter Second Score:";
cin >> score2;
cout << "Please enter Third Score:";
cin >> score3;
if (score1 >= 0 && score2 >= 0 && score3 >= 0) {
pp.setName(name);
pp.setScore1(score1);
pp.setScore2(score2);
pp.setScore3(score3);
double total = pp.getTotal();
ga.setScore(total);
cout << endl << "########## Welcome To Grading Project ##########" << endl;
cout << " Name of the student=" << name << " Total marks in 100=" << total << " Grade=" << ga.getLetterGrade() << endl;
cout << "####################################################" << endl;
}
else {
cout << "You have to enter a postive score!!!" << endl;
}
return 0;
}
-------------------------------------------------------------------------------------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.