Please Help me on my program am stuck! I keep getting too few arguments for your
ID: 3551825 • Letter: P
Question
Please Help me on my program am stuck! I keep getting too few arguments for your function .. The following below is what I am suppose to have .
int () In a loop that executes as long as the user has a set of scores to execute, main will prompt the user for the highest and lowest valid scores and then call getValue() 5 times to get 5 test scores. main will then call calcAverage() passing it the five scores. calcAverage returns the average of the four highest scores and main will print the average.
This is what I got so far I dont know what to do and its due by midnight .. I am new in c++
include <iostream>
using namespace std;
void getValue( double, double);
void calcAverage( double,double, double, double , double );
int findLowest( int,int,int,int, int );
int main()
{
string again;
double s1,s2,s3,s4,s5;
again = "Y";
string Repeat = "Enter another set of scores again? (Y/N) ";
double lowerBound, upperBound;
do
{
int s1,s2,s3,s4,s5;
getValue(s1);
getValue(s2);
getValue(s3);
getValue(s4);
getValue(s5);
calcAverage(s1,s2,s3,s4,s5);
cout<<Repeat ;
cin>> again;
cout<<endl;
cout<<endl;
}
while (again =="y" or again=="Y");
cout<<"Bye! .. Have a nice day!"<< endl;
return 0;
}
void getValue(double lowerBound, double upperBound)
{
do
{
cout<<"Enter Highest Score";
cin>> upperBound;
cout<<"Enter LowerScore";
cin>>lowerBound;
cout<<"Enter a value in the range (0-"<<upperBound<<")";
cin>>upperBound;
if(upperBound<0||upperBound>100)
cout<<"number out of range-try again ";
}
while(upperBound<0||upperBound>100);
//return;
}
void calcAverage( double s1, double s2, double s3, double s4, double s5 )
{
double average;
int low,total;
low=findLowest(s1,s2,s3,s4,s5);
total=s1+s2+s3+s4+s5-low;
average=total/4.;
cout<<endl;
cout<<endl;
cout<<"The average of the top 4 grades is "<<average<<endl;
return;
}
int findLowest( int s1, int s2, int s3, int s4, int s5 )
{int low;
low=s1;
if(s2<low)
low=s2;
if(s3<low)
low=s3;
if(s4<low)
low=s4;
if(s5<low)
low=s5;
return low;
}
That should be my output
Explanation / Answer
#include <iostream>
using namespace std;
int getValue( int, int);
void calcAverage( int,int,int,int,int );
int findLowest( int,int,int,int, int );
int main()
{
string again;
int s1,s2,s3,s4,s5;
again = "Y";
string Repeat = "Enter another set of scores again? (Y/N) ";
int lowerBound, upperBound;
do
{
cout<<"Enter Highest Score";
cin>> upperBound;
cout<<"Enter LowerScore";
cin>>lowerBound;
s1=getValue(upperBound,lowerBound);
s2=getValue(upperBound,lowerBound);
s3=getValue(upperBound,lowerBound);
s4=getValue(upperBound,lowerBound);
s5=getValue(upperBound,lowerBound);
calcAverage(s1,s2,s3,s4,s5);
cout<<Repeat ;
cin>> again;
cout<<endl;
cout<<endl;
}
while (again =="y" or again=="Y");
cout<<"Bye! .. Have a nice day!"<< endl;
return 0;
}
int getValue(int upperBound,int lowerBound)
{
int s;
cout<<"Enter a value in the range ("<<lowerBound<<"-"<<upperBound<<") ";
cin>>s;
if(lowerBound<=s && upperBound>=s)
return s;
else return 0;
}
void calcAverage(int s1, int s2, int s3, int s4, int s5 )
{
double average;
int low,total;
low=findLowest(s1,s2,s3,s4,s5);
total=s1+s2+s3+s4+s5-low;
average=total/4.0;
cout<<endl;
cout<<endl;
cout<<"Average score is "<<average<<endl;
return;
}
int findLowest( int s1, int s2, int s3, int s4, int s5 )
{int low;
low=s1;
if(s2<low)
low=s2;
if(s3<low)
low=s3;
if(s4<low)
low=s4;
if(s5<low)
low=s5;
return low;
}