Question
Please help modify this code so that there are no cout/cin statements in the int main () function at the bottom. Thank you! #include #include
Please help modify this code so that there are no cout/cin statements in the int main () function at the bottom. Thank you!
#include
cin >> *score;
while (*score < 0 || *score>10) { cout << " Rejected, try again... "; cin >> *score; } }
float findLowest(float scores[], int s) { float currLow; currLow = scores[0];
for (int i = 0; i < s; i++) {
if (scores[i] < currLow) currLow = scores[i]; } return(currLow); }
float findHighest(float scores[], int s) { float currHigh;
currHigh = scores[0];
for (int i = 0; i < s; i++) { if (scores[i] > currHigh) currHigh = scores[i]; } return(currHigh); } void calcScore(float scores[], int s) {
int lowFlag = -1, highFlag = -1; float Sum = 0, scoreAvg, currLow, currHigh; currLow = findLowest(scores, s); currHigh = findHighest(scores, s); for (int i = 0; i < s; i++) { if (scores[i] == currLow && lowFlag == -1) { scores[i] = 0; lowFlag = 0; }
if (scores[i] == currHigh && highFlag == -1) { scores[i] = 0; highFlag = 0; } }
for (int i = 0; i < s; i++) { Sum = Sum + scores[i]; }
scoreAvg = Sum / 3;
cout << " Average Score: " << scoreAvg << setprecision(2) << fixed << endl << endl; } double getSmallest(const double theScores[], int numScores); int main() { double getSmallest; float scores[5]; int s = 5; float avgScore; cout << " Enter each Judge's score." << setprecision(2) << fixed << endl << endl << endl; for (int i = 0; i < 5; i++) { cout << " Enter Judge #" << i + 1 << " score: "; getJudgeData(&scores[i]); cout << setprecision(2) << fixed << endl; } calcScore(scores, s); cout << setprecision(2) << fixed << endl; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started