#include <iostream> #include <iomanip> using namespace std; int main() { int sco
ID: 3573337 • Letter: #
Question
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int score[12];
int Lab[12];
int index;
for (index=1; index<13;index++)
{
cout<<" Enter score for Lab "<<Lab[12]<<": ";
cin>>score[11];
}
return 0;
}
Using the C++ program I wrote above Can someone please rewrite this so that it calculates how many full scores you recieved in your labs. If you get more than 5 full scores write "GOOD WORK" otherwise write "NEED TO WORK HARDER"(Hint: Write another for loop to check of it is a full score (of 100%) and keep count of the full scores.Outside the loop write the message depending on the number of full score )
Please write in C++ :)
Explanation / Answer
#include <iostream>
#include <iomanip>
/*define FULLSCORE to 100 */
#define FULLSCORE 100
using namespace std;
/*scorecount that count how many full scores you received in your labs*/
int scorecount(int score[])
{
int i;
int fullScoreCount=0;
cout<<"Full Score is:"<<FULLSCORE<<endl;
for(i=1;i<13;i++)
{
cout<< "Lab["<<i<<"] score is:" <<score[i]<<endl;
if(score[i]==FULLSCORE)
{
fullScoreCount++;
}
}
return fullScoreCount;
}
/*main function*/
int main()
{
int score[12];
int Lab[12];
int index;
int fs;
for (index=1; index <13;index++)
{
cout<<" Enter score for Lab "<<"Lab["<<index<<"]: ";
cin>>score[index];
}
/*calling scorecount function*/
fs=scorecount(score);
/*If you get more than 5 full scores write "GOOD WORK" otherwise write "NEED TO WORK HARDER" */
if(fs>5)
{
cout<<"GOOD WORK"<<endl;
}
else
{
cout<<"NEED TO WORK HARDER"<<endl;
}
return 0;
}
--------------------------------------------------------------------
output sample 1:-
Enter score for Lab Lab[1]: 100
Enter score for Lab Lab[2]: 100
Enter score for Lab Lab[3]: 100
Enter score for Lab Lab[4]: 89
Enter score for Lab Lab[5]: 55
Enter score for Lab Lab[6]: 100
Enter score for Lab Lab[7]: 100
Enter score for Lab Lab[8]: 60
Enter score for Lab Lab[9]: 99
Enter score for Lab Lab[10]: 90
Enter score for Lab Lab[11]: 96
Enter score for Lab Lab[12]: 89
Full Score is:100
Lab[1] score is:100
Lab[2] score is:100
Lab[3] score is:100
Lab[4] score is:89
Lab[5] score is:55
Lab[6] score is:100
Lab[7] score is:100
Lab[8] score is:60
Lab[9] score is:99
Lab[10] score is:90
Lab[11] score is:96
Lab[12] score is:89
NEED TO WORK HARDER
-----------------------------------------
output sample 2:-
Enter score for Lab Lab[1]: 100
Enter score for Lab Lab[2]: 89
Enter score for Lab Lab[3]: 100
Enter score for Lab Lab[4]: 100
Enter score for Lab Lab[5]: 99
Enter score for Lab Lab[6]: 90
Enter score for Lab Lab[7]: 78
Enter score for Lab Lab[8]: 100
Enter score for Lab Lab[9]: 100
Enter score for Lab Lab[10]: 100
Enter score for Lab Lab[11]: 56
Enter score for Lab Lab[12]: 88
Full Score is:100
Lab[1] score is:100
Lab[2] score is:89
Lab[3] score is:100
Lab[4] score is:100
Lab[5] score is:99
Lab[6] score is:90
Lab[7] score is:78
Lab[8] score is:100
Lab[9] score is:100
Lab[10] score is:100
Lab[11] score is:56
Lab[12] score is:88
GOOD WORK
---------------------------------------------------------------------------------------------
If you have any query, please feel free to ask.
Thanks a lot.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.