The goal of my program is to do the following: to make two functions called findSmallest and computeAvg. Then the user is to enter 4 integer scores from 1 to 25 and validate that the scores entered are within range. If the numbers are within range, call on function computeAvg to compute and return the average of the best three scores. computeAvg must use the result returned from findSmallest which finds the smallest of the scores.
Ask if the user wishes to enter another 4 sets of scores and repeat the process, and stop otherwise.
My code thus far is the following, and I need some guidance to finish it:
//Program that consists of two functions findSmallest and computeAvg
#include<iostream>
using namespace std;
double ComputeAvg(int x,int y,int z,int f, double Avg, double Sum);
double findSmallest(int x, int y, int z, int f, double SmallestNumber);
int main()
{
int a,b,c,d;
double Avg;
cout<<"Enter four test scores (1 to 25):";
cin>>a>>b>>c>>d;
Avg= ComputeAvg(int a,int b,int c,int d,double Avg,double Sum);
cout<<"After dropping the lowest score your average is?"<<Avg<<endl;
double Ans;
cout<<"Would you like to try again (y/n)?";
cin>>Ans;
if(Ans=y)
else
}
double findSmallest(int a, int b, int c, int d,double SmallestNumber)
{
if(a<b && a<c && a<d)
{
SmallestNumber=a;
}
else if(b<a && b<c && b<d)
{
SmallestNumber=b;
}
else if(c<a && c<b && c<d)
{
SmallestNumber=c;
}
else
SmallestNumber=d;
return SmallestNumber;
}
double ComputeAvg(int a, int b,int c, int d,double Avg,double Sum)
{
Sum= a+b+c+d;
Avg= (Sum-findSmallest(a,b,c,d))/3.0;
return Avg;
}
Aucun commentaire:
Enregistrer un commentaire