Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- double num;
- char degree;
- double C2F(double);
- double K2F(double);
- double N2F(double);
- cout << "This temperature conversion program converts other temperature types to Fahrenheit" << endl;
- cout << "The temperature types are : " << endl;
- cout << "C - Celcius" << endl;
- cout << "K - Kelvin" << endl;
- cout << "N - Newton" << endl;
- cout << "X - eXit" << endl;
- cout << "To use the converter, you must input a value and one of the temperature types." << endl;
- cout << "For example, 32 C converts 32 degrees from Celsius to Fahrenheit" << endl;
- cout << "Please enter a value and its type to be converted" << endl;
- cin >> num >> degree;
- while (degree != 'X')
- {
- cout << "Please enter a value and its type to be converted" << endl;
- cin >> num >> degree;
- switch (degree)
- {
- case 'C':
- cout << num << degree << " is " << C2F(num) << " in Fahrenheit" << endl;
- break;
- case 'K':
- cout << num << degree << " is " << K2F(num) << " in Fahrenheit " << endl;
- break;
- case 'N':
- cout << num << degree << " is " << N2F(num) << " in Fahrenheit " << endl;
- break;
- default:
- cout << "Invalid input" << endl;
- break;
- case 'X':
- cout << "eXit" << endl;
- exit(0);
- }
- }
- return 0;
- }
- double C2F(double num)
- {
- double convert1 = (num - 273.15) * 1.8000 + 32;
- return convert1;
- }
- double K2F(double num)
- {
- double convert2 = num * 9 / 5 + 32;
- return convert2;
- }
- double N2F(double num)
- {
- double convert3 = num * 60 / 11 + 32;
- return convert3;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement