Hi all - I'm new to programming and still learning. I've made a program that lets the user convert temperature from F to C and C to F, as many times as the user wants. Most of the program is pretty much done but I am stuck on this part:
Question: I can't seem to figure out how to separate the fahrenheit and centigrade outputs, and averaging each of them separately. A fahrenheit average and a centigrade average.
Here is the code:
Question: I can't seem to figure out how to separate the fahrenheit and centigrade outputs, and averaging each of them separately. A fahrenheit average and a centigrade average.
Here is the code:
Code:
cout<<"\nEnter the amount of times you want to run this program: ";
cin>>num1;
for(cnt=1; cnt<=num1; cnt++)
{
cout<<"\n\nFahrenheit to Celcius - Press C.\n";
cout<<"Celsius to Fahrenheit - Press F.\n\n";
cin>>temp;
if (temp=='C' || temp=='c')
{cout<<"\nEnter temperature in Fahrenheit: ";
cin>>fahr;
celsius = (fahr-32)*5/9;
cout<<"\n\nTemperature in Celsius is:";
cout<<celsius <<"\n\n\n";
}
if (temp=='F' || temp=='f')
{cout<<"\nEnter temperature in Celsius: ";
cin>>celsius;
fahr = 32 + celsius*9/5;
cout<<"\nTemperature in Fahrenheit is: ";
cout<<fahr <<"\n\n\n";
}
if (temp!='F' && temp!='f' && temp!='C' && temp!='c')
cout<<"\nThe rules of the Matrix give you no third choice. "
<<"\nChoose F or C.\n\n\n";
}
Comment