Hi, I have a temperature conversion program down pat, but I was told to
add an average, meaning, i need to get the average temperature for as
many times as it was entered. i do not know where to start, and my
stpid book doesnt seem to help.
here is my program
#include <iostream.h>
void main( )
{
int num1, num2, count;
char choice, again;
count=1;
do
{cout<<"This Program will Convert Temperature"<<e ndl<<endl;
cout<<"Press 1 to Convert Fahrenheight to Celcius"<<endl;
cout<<"Press 2 to Convert Celcius to Fahrenheight"<< endl<<endl;
cin>>choice;
switch (choice)
{ case '1':
cout<<endl<<"Pl ease Type In the Fahrenheight Temperature: ";
cin>>num1;
cout<<endl<<"Th e Temperature in Celcius is:
"<<(num1-32)*5/9<<endl<<endl;
cout<<"Thank You for Using Temperature Converter v.1"<<endl<<end l;
break;
case '2':
cout<<endl<<"Pl ease Type In the Celcius Temperature: ";
cin>>num2;
cout<<endl<<"Th e Temperature in Fahrenheight is:
"<<num2*9/5+32<<endl<<end l;
cout<<"Thank You for Using Temperature Converter v.1"<<endl<<end l;
break;
default:
cout<<"Invalid Entry, Try Again";
}
count++;
cout<<"Type N to stop program";
cin>>again;
} while (again!= 'N' && again!='n');
}
add an average, meaning, i need to get the average temperature for as
many times as it was entered. i do not know where to start, and my
stpid book doesnt seem to help.
here is my program
#include <iostream.h>
void main( )
{
int num1, num2, count;
char choice, again;
count=1;
do
{cout<<"This Program will Convert Temperature"<<e ndl<<endl;
cout<<"Press 1 to Convert Fahrenheight to Celcius"<<endl;
cout<<"Press 2 to Convert Celcius to Fahrenheight"<< endl<<endl;
cin>>choice;
switch (choice)
{ case '1':
cout<<endl<<"Pl ease Type In the Fahrenheight Temperature: ";
cin>>num1;
cout<<endl<<"Th e Temperature in Celcius is:
"<<(num1-32)*5/9<<endl<<endl;
cout<<"Thank You for Using Temperature Converter v.1"<<endl<<end l;
break;
case '2':
cout<<endl<<"Pl ease Type In the Celcius Temperature: ";
cin>>num2;
cout<<endl<<"Th e Temperature in Fahrenheight is:
"<<num2*9/5+32<<endl<<end l;
cout<<"Thank You for Using Temperature Converter v.1"<<endl<<end l;
break;
default:
cout<<"Invalid Entry, Try Again";
}
count++;
cout<<"Type N to stop program";
cin>>again;
} while (again!= 'N' && again!='n');
}
Comment