I am trying to write this "program" for my distance ed course and I almost have it done I just can't figure out how to get the values from the function BoxDimensions into the function DisplayData so that it can print out the dimensions. Help????
Thanks.
#include <iostream>
using namespace std;
double BoxDimensions (double a, double b, double c, double d)
{
if (a==0)
{a=d/b/c;
return a;}
else if (b==0)
{b=d/a/c;
return b;}
else if (c==0)
{c=d/a/b;
return c;}
else if (d==0)
{d=a*b*c;
return d;}
return 0;
cout<<endl;
}
double DisplayData (double f, double g, double h, double i)
{
double e;
cout<< "Length: "<<f<<endl;
cout<< "Width: "<<g<<endl;
cout<< "Height: "<<h<<endl;
cout<< "Volume: "<<i<<endl;
e=f*g;
cout<<"Area: "<<e<<endl;
return 0;
cout<<endl;
}
int ProcessAnother()
{
char again= 'y';
for (again=again; (again=='y' ||again=='Y'); again=again)
{
cout<<"Would you like to run this program again (y or n)?"<<endl;
cin>>again;
cout<<endl;
if (again=='n' || again =='N')
{
again='n';
}
if (again=='y' || again=='Y')
{
double l,w,h,v;
cout<<"Please enter dimensions. For the dimension you wish to find please enter a 0. "<<endl;
cout<<"Length: ";
cin>> l;
cout<<"Width: ";
cin>> w;
cout<<"Height: ";
cin>> h;
cout<<"Volume: ";
cin>> v;
cout<<endl<<endl;
cout<<BoxDimensions(l,w,h,v)<<endl<<endl;
cout<<DisplayData(l,w,h,v)<<endl;
cout<<ProcessAnother()<<endl;
}
}
return 0;
cout<<endl;
}
int main()
{
double l,w,h,v;
cout<<"Please enter dimensions. For the dimension you wish to find please enter a 0. Only enter one 0 per calculation. "<<endl;
cout<<"Length: ";
cin>> l;
cout<<"Width: ";
cin>> w;
cout<<"Height: ";
cin>> h;
cout<<"Volume: ";
cin>> v;
cout<<endl<<endl;
cout<<BoxDimensions(l,w,h,v)<<endl<<endl;
cout<<DisplayData(l,w,h,v)<<endl;
cout<<ProcessAnother()<<endl;
}