0% found this document useful (0 votes)
42 views2 pages

Programming Assignment11

This document is a C++ program for a temperature conversion calculator that allows users to convert temperatures between Fahrenheit, Celsius, and Kelvin. It prompts the user to select a conversion type, takes the input temperature, performs the conversion, and displays the results. The program also offers the option to perform additional conversions until the user decides to quit.

Uploaded by

Xahid Yousaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

Programming Assignment11

This document is a C++ program for a temperature conversion calculator that allows users to convert temperatures between Fahrenheit, Celsius, and Kelvin. It prompts the user to select a conversion type, takes the input temperature, performs the conversion, and displays the results. The program also offers the option to perform additional conversions until the user decides to quit.

Uploaded by

Xahid Yousaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include <iostream.

h>
main()
{
double f_temp, k_temp, c_temp, temp;
char ch, quit;
cout << " *********** Temprature Conversion Calculator **************";
cout << "\n\n Please enter the temprature unit for which you want the
coverison ";
cout << "\n 1. F for Fahrenheit to Celcius and Kalvin";
cout << "\n 2. C for Celsius to Fahrenheit and Kalvin";
cout << "\n 3. K for Kalvin to Fahrenheit and Celcius";
startagain:
cout << "\n\n Please enter you choice: ";
cin >> ch;
switch(ch)
{
case 'f':
case 'F':
cout << " Please enter temprature in Farhenheit: ";
cin >> f_temp;
c_temp = (f_temp - 32) * 5/9;
k_temp = (f_temp + 459.67) * 5/9;
cout << " Celcius =" << c_temp;
cout << "\n Kelvin =" << k_temp;
cout << "\n Do you want to calculate another value (y/n): ";
cin >> quit;
if (quit == 'y' || quit == 'Y')
goto startagain;
break;
case 'c':
case 'C':
cout << " Please enter temprature in Celcius: ";
cin >> c_temp;
k_temp = c_temp + 273.15 ;
f_temp = c_temp * 9/5 + 32;
cout << " Kelvin =" << k_temp;
cout << "\n Farhenheit =" << f_temp;
cout << "\n Do you want to calculate another value (y/n): ";
cin >> quit;
if (quit == 'y' || quit == 'Y')
goto startagain;
break;
case 'k':
case 'K':
cout << " Please enter temprature in Kelvin: ";
cin >> k_temp;
c_temp = k_temp - 273.15 ;
f_temp = (k_temp - 273.14) * 9/5 + 32;
cout << " Celcius =" << c_temp;
cout << "\n Farhenheit =" << f_temp;
cout << "\n Do you want to calcute another value (y/n): ";

cin >> quit;


if (quit == 'y' || quit == 'Y')
goto startagain;
break;
default:
cout << "\n Invalid Choice";
}
cout << endl<<endl;
system("pause");
}

You might also like