In: Computer Science
Develop a program that calculates the final score and the average score for a student from his/her (1)class participation, (2) test, (3) assignment, (4) exam, and (5) practice scores.
The user should enter the name of the student and scores ranging from 0 to 100 for each grading item.
The final score is the sum of all grading items.
The average score is the average of all grading items.
Here is a sample output of the program:
Enter the Student's name: John Smith
Enter Class Participation Score ranging from 0 to 100:
89
Enter Test Score ranging from 0 to 100: 87
Enter Assignment Score ranging from 0 to 100:
67
Enter Exam Score ranging from 0 to 100: 99
Enter Practice Score ranging from 0 to 100:
80
John Smith: Final Score: 422 Average Score:
84.4
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
_________________
#include <iostream>
#include<cmath>
#include<iomanip>
using namespace std;
//Declaring the function
double getValidScore();
int main()
{
//setting the precision to two decimal places
std::cout << std::setprecision(2) <<
std::fixed;
//Declaring variables
string name;
double
partciScore,testScore,assignScore,examScore,practiScore;
double tot,avg=0.0;
//Getting the input entered by the user
cout<<"Enter Enter the Student's name: ";
getline(cin,name);
cout<<"Enter Class Participation Score ranging from 0 to
100:";
partciScore=getValidScore();
cout<<"Enter Test Score ranging from 0 to 100:";
testScore=getValidScore();
cout<<"Enter Assignment Score ranging from 0 to 100:";
assignScore=getValidScore();
cout<<"Enter Exam Score ranging from 0 to 100:";
examScore=getValidScore();
cout<<"Enter Practice Score ranging from 0 to 100:";
practiScore=getValidScore();
//Performing calculations
tot=partciScore+testScore+assignScore+examScore+practiScore;
avg=tot/5;
//Displaying the output
cout<<name<<": Final Score: "<<tot<<"
Average Score: "<<avg<<endl;
return 0;
}
/* This function will get and return
* the valid score entered by the user
*/
double getValidScore()
{
double score;
while(true)
{
cin>>score;
if(score<0 ||
score>100)
{
cout<<"**
Invalid.Must be between 0-100 **"<<endl;
}
else
{
break;
}
}
return score;
}
___________________________
Output:
_______________Could you plz rate me well.Thank
You