The first image is the program needed for problem 23 and the second image is the
ID: 3939301 • Letter: T
Question
The first image is the program needed for problem 23 and the second image is the question/problem.. but I need help solving it.
//Displ won, the averape anount won, and /lthe day namber of the highest mount wor ays the total amount //created/revised /created/revised by cyour by on us ing nanespace std //function protatypes void getTotal: double getAvEC) int getiighoay) FInt sain) t maint) iat "imingsts)- 25ee, wee, 2400, se“, s40e); Let total e double average int highoay cout Total onount won:" totalExplanation / Answer
#include <iostream>
#include<iomanip>
using namespace std;
int getTotal();
double getAvg();
int getHighDay();
int winnings[5]= {12540,5000,2400,15600,5400};
int main()
{
int total=getTotal();
double average=getAvg();
int highDay=getHighDay();
cout<<fixed<<setprecision(3);
cout << "Total amount won: $"<<total << endl;
cout << "Dialy average amount won: $"<<average<< endl;
cout << "The contestent's highest amount won was on day: "<<highDay<< endl;
return 0;
}
int getTotal()
{
int total=0;
for(int i=0; i<5; i++)
{
total+=winnings[i];
}
return total;
}
double getAvg()
{
return (double)getTotal()/5.0;
}
int getHighDay()
{
int max=winnings[0];
int day=0;
for(int i=1; i<5; i++)
{
if(max<winnings[i])
{
max=winnings[i];
day=i;
}
}
return day+1;
}
OUTPUT:
Total amount won: $40940
Dialy average amount won: $8188.000
The contestent's highest amount won was on day: 4
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.