can some one please help me I need to write a program with 3 function, findaverage, howfarapart and whichisclosest. I got the first one (findaverage for three #) but im having problem with calling howfarapart cause it supposed to receive only two parameters. average and one of the three integer value.
example, 5.40 and 7 it returns the value 1.60; 5.40 and 5 it returns the value0.40
here is a copy of the program so far.
#include<iostre am>
using namespace std;
//void introduction();
void findaverage(dou ble,double,doub le);
// void howfarapart(dou ble, double);
int main()
{
double numone,numsec,n umthird,average ,num;
cout<<"Misael Caballero, Project #3 \n"
<<"This is a program that computes the average of three given numbers \n\n";
cout<<"Type in three integer values from 1 to 100! \n";
cin>>numone>>nu msec>>numthird;
cout<<"the three original integers are:"<<numone<< ","<<numsec<<", "<<numthird<<"\ n"<< endl;
findaverage( numone, numsec, numthird); //function is call here
return 0;
}
void findaverage(dou ble numone, double numsec, double numthird)
{
double average,num,how farapart;
average=(numone +numsec+numthir d)/3;
cout<<"the average is "<<average<<"\n \n";
//num=howfarapart (numone, numsec, numthird);
}
void howfarapart(dou ble average, double num)
{
double first,second,th ird;
double numone,numsec,n umthird;
first=average-num;
cout<<"the first is "<<first<<" \n";
second=average-num;
cout<<"the second is "<<second<<"\n" ;
third=average-num;
cout<<"the third is "<<third<<"\n\n ";
return;
}
example, 5.40 and 7 it returns the value 1.60; 5.40 and 5 it returns the value0.40
here is a copy of the program so far.
#include<iostre am>
using namespace std;
//void introduction();
void findaverage(dou ble,double,doub le);
// void howfarapart(dou ble, double);
int main()
{
double numone,numsec,n umthird,average ,num;
cout<<"Misael Caballero, Project #3 \n"
<<"This is a program that computes the average of three given numbers \n\n";
cout<<"Type in three integer values from 1 to 100! \n";
cin>>numone>>nu msec>>numthird;
cout<<"the three original integers are:"<<numone<< ","<<numsec<<", "<<numthird<<"\ n"<< endl;
findaverage( numone, numsec, numthird); //function is call here
return 0;
}
void findaverage(dou ble numone, double numsec, double numthird)
{
double average,num,how farapart;
average=(numone +numsec+numthir d)/3;
cout<<"the average is "<<average<<"\n \n";
//num=howfarapart (numone, numsec, numthird);
}
void howfarapart(dou ble average, double num)
{
double first,second,th ird;
double numone,numsec,n umthird;
first=average-num;
cout<<"the first is "<<first<<" \n";
second=average-num;
cout<<"the second is "<<second<<"\n" ;
third=average-num;
cout<<"the third is "<<third<<"\n\n ";
return;
}
Comment