Hi all beginner hear and im having trouble with the program im writing, below is my code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;
void description();
char temperatureScale(char A);
double temperatureReading(double &num);
void convertCtoF();
void convertFtoC();
void Results();
char tempChoice;
double temperature;
float Ftemp, Ctemp, resultF, resultC;
int main()
{
description();
char choice;
choice = temperatureScale(choice);
double num;
temperatureReading(num);
convertFtoC();
convertCtoF();
Results();
}
void description()
{
cout<<"This program will convert a temperature reading provided in " <<endl;
cout<<"either Fahrenheit or Celcius to the other measurment scale. " <<endl;
cout<<" " <<endl;
}
char temperatureScale(char A)
{
char tempChoice;
cout<<"What temperature scale did you use (F = Fahrenheit; C = Celsius)? ";
cin>>tempChoice;
}
double temperatureReading(double &num)
{
cout<<"Please enter your temperature reading (in degrees): ";
cin>>temperature;
}
void convertFtoC()
{
float Ctemp;
Ctemp = (temperature - 32)/1.8;
}
void convertCtoF()
{
float Ftemp;
Ftemp = 1.8 * temperature +32;
resultF = Ftemp;
}
void Results()
{
cout<<"Your temperature reading converts as follows: " <<endl;
cout<<" "<<endl;
cout<<" Fahrenheit: " <<resultF <<endl;
cout<<" Celsius: " <<resultC <<endl;
}
|
It needs to output like this:
Your temperature reading converts as follows:
Fahrenheit: (based on what scale the user selects)
Celcius: (based on the scale the user selects)
------
If the user selects Fahrenheit then the value they enter should just get put in for the results and the only calculation you will get is Celsius and vice versa for the Celsius data.
When I run my program i get this:
This program will convert a temperature reading provided in
either Fahrenheit or Celcius to the other measurment scale.
What temperature scale did you use (F = Fahrenheit; C = Celsius)? F
Please enter your temperature reading (in degrees): 212
Your temperature reading converts as follows:
Fahrenheit: 413.6
Celsius: 100
Please help as you can see if i use Fahrenheit my calculation is right but my celsius isnt and vce versa for inputing C
Thanks.