Advertisement
invention8

FahrenheitToCelsius

Mar 6th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1.  
  2. // Created by Tan
  3. // Program designed to convert Fahrenheit to Kelvin, and allow additional incremental conversions.
  4. // Formula used:  Kelvin = (Fahrenheit - 32) * 5 / 9 + 273.15
  5. // Derived from these equations, where the variables are their corresponding numbers degrees, Fahrenheit is °F, etc:
  6. // (Fahrenheit - 32) * 5 / 9 = Celsius , Kelvin = Celsius - 273.15
  7.  
  8. #include "stdafx.h" // Precompiled Header
  9. #include <iostream> // Needed for Cin Cout
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14.     double Kelvin, Fahrenheit, Modifier; // Names of variables in our equations.
  15.     cout << "+++++++++++++++++++++++++++++++++++++++" << endl;
  16.     cout << "Fahrenheit to Kelvin Converter by Tan" << endl;
  17.     cout << "Input the Fahrenheit temperature you'd like converted to Kelvin." << endl;
  18.     cout << "Formula this program uses: Kelvin = (Fahrenheit - 32) * 5 / 9 + 273.15 " << endl;
  19.     cout << "+++++++++++++++++++++++++++++++++++++++" << endl;
  20.  
  21.     cout << "Choose the initial Fahrenheit temperature to convert, then add amounts modifying this number." << endl;
  22.     cin >> Fahrenheit; // Fahrenheit is stored as a number
  23.     Modifier = 0; // Modifier is initially zero.
  24.  
  25.     do
  26.     {
  27.         Kelvin = (Fahrenheit - 32) * 5 / 9 + 273.15;
  28.  
  29.         cout << Fahrenheit << " degrees Fahrenheit is equivalent to " << Kelvin << " degrees Kelvin." << endl;
  30.         cin >> Modifier; // Modifier for Fahrenheit
  31.  
  32.         Fahrenheit = Fahrenheit + Modifier; // The incremental is added to the current value of Fahrenheit and a new equation giving a value of Kelvin is output.
  33.  
  34.     } while (Fahrenheit <= 200); // End the reading of incremental responses if the combined amount of Fahrenheit is ever equal to or greater than 200.
  35.  
  36.  
  37.     system("pause");
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement