THIS IS A C++ CODE. please help need code with all the constraints given below Y
ID: 3884295 • Letter: T
Question
THIS IS A C++ CODE. please help need code with all the constraints given below
Your friend has asked you to help them with a project. He needs to calculate his grades, but is finding it difficult to operate a calculator (too hard). Create a program which will accept an unlimited num- ber of scores and calculates the average score. You will also need to prompt for the total points possible.
Use object- oriented progrramming techniques
Use a dynamically allocated array to handle an unlimited number of test scores.
Create a Grade class which holds the test score and the letter grade. Use an assert to protect the letter grade by not allowing negative scores.
Create a simple menu: 1 - help, 2 - enter grade, 3 - quit. Use char user_menu; for menu input. If incorrect value entered, display the value in the error message (ie, 4 is not a valid input).
When quitting, display a list of scores and average grade with appropriate headings.
1)give average letter grade and average percentage.
2)sort the input given.
3)able to input class names for the grade.
4)use assert to end the program if the user chooses quit in the main menu.
5)using input validation for the main menu and all other places with user input.
Explanation / Answer
class Grade
{
public:
vector<int> vec;
void exit();
void menu();
}
int main()
{
int input,grade;
Grade g;
while(1)
{
g.menu();
cin>>input;
if(input>3||input<1)
{
cout<<input<<"is not a valid input,please enter a valid input"<<" ";
}
if(input==2)
{
cin>>grade;
g.vec.push_back(grade);
}
if(input==3)
{
g.quit();
break;
}
}
}
void Grade :: menu()
{
cout<<"1.help"<<" "<<"2.enter grade"<<" "<<"quit"<<" ";
}
void Grade::quit()
{
int size = vec.size();
for(int i=0;i<size;i++)
{
avg+=vec(i);
}
cout<<avg;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.