At Westonci.ca, we provide clear, reliable answers to all your questions. Join our vibrant community and get the solutions you need. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately. Get immediate and reliable solutions to your questions from a community of experienced professionals on our platform.
Sagot :
Answer:
#include <iomanip>
#include<iostream>
using namespace std;
int main(){
char name[100];
float classp, test, assgn, exam, prctscore,ave;
cout<<"Student Name: ";
cin.getline(name,100);
cout<<"Class Participation: "; cin>>classp;
while(classp <0 || classp > 100){ cout<<"Class Participation: "; cin>>classp; }
cout<<"Test: "; cin>>test;
while(test <0 || test > 100){ cout<<"Test: "; cin>>test; }
cout<<"Assignment: "; cin>>assgn;
while(assgn <0 || assgn > 100){ cout<<"Assignment: "; cin>>assgn; }
cout<<"Examination: "; cin>>exam;
while(exam <0 || exam > 100){ cout<<"Examination: "; cin>>exam; }
cout<<"Practice Score: "; cin>>prctscore;
while(prctscore <0 || prctscore > 100){ cout<<"Practice Score: "; cin>>prctscore; }
ave = (int)(classp + test + assgn + exam + prctscore)/5;
cout <<setprecision(1)<<fixed<<"The average score is "<<ave;
return 0;}
Explanation:
The required parameters such as cin, cout, etc. implies that the program is to be written in C++ (not C).
So, I answered the program using C++.
Line by line explanation is as follows;
This declares name as character of maximum size of 100 characters
char name[100];
This declares the grading items as float
float classp, test, assgn, exam, prctscore,ave;
This prompts the user for student name
cout<<"Student Name: ";
This gets the student name using getline
cin.getline(name,100);
This prompts the user for class participation. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)
cout<<"Class Participation: "; cin>>classp;
while(classp <0 || classp > 100){ cout<<"Class Participation: "; cin>>classp; }
This prompts the user for test. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)
cout<<"Test: "; cin>>test;
while(test <0 || test > 100){ cout<<"Test: "; cin>>test; }
This prompts the user for assignment. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)
cout<<"Assignment: "; cin>>assgn;
while(assgn <0 || assgn > 100){ cout<<"Assignment: "; cin>>assgn; }
This prompts the user for examination. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)
cout<<"Examination: "; cin>>exam;
while(exam <0 || exam > 100){ cout<<"Examination: "; cin>>exam; }
This prompts the user for practice score. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)
cout<<"Practice Score: "; cin>>prctscore;
while(prctscore <0 || prctscore > 100){ cout<<"Practice Score: "; cin>>prctscore; }
This calculates the average of the grading items
ave = (int)(classp + test + assgn + exam + prctscore)/5;
This prints the calculated average
cout <<setprecision(1)<<fixed<<"The average score is "<<ave;
Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Westonci.ca is your trusted source for answers. Visit us again to find more information on diverse topics.