[ create a new paste ] login | about

Link: http://codepad.org/IRJqQsTW    [ raw code | output | fork ]

C++, pasted on Apr 12:
#include <iostream>
#include <iomanip>
using namespace std;

void temperatureReading(double &);
void convertCtoF(double temperature);
void convertFtoC(double temperature);
void description();

int main()
{
  double temperature;
  description();
  temperatureReading(temperature);
  convertCtoF(temperature);
  convertFtoC(temperature);
  return 0;
}
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;
}

void temperatureReading(double &num)
{
  cout<<"Please enter your temperature reading (in degrees): ";
  num=20;
}

void convertFtoC(double temperature)
{
      float Ctemp;
      Ctemp = (temperature - 32)/1.8;
      cout<<"Fahrenheit: " <<setprecision(2) <<Ctemp <<"F"<<endl;
      }

void convertCtoF(double temperature)
{
  float Ftemp;
  Ftemp = 1.8 * temperature +32;
      cout<<"                                          " <<endl;
      cout<<"Your temperature is converted as follows: " <<endl;
      cout<<"Celsius: " <<setprecision(2) <<Ftemp <<"C"<<endl;
}


Output:
1
2
3
4
5
6
7
This program will convert a temperature reading provided in 
either Fahrenheit or Celcius to the other measurment scale. 
                                                            
Please enter your temperature reading (in degrees):                                           
Your temperature is converted as follows: 
Celsius: 68C
Fahrenheit: -6.7F


Create a new paste based on this one


Comments: