CYBERMIX | FORUM

Hello, Guest !

We would like to invite you to join our community.

Register & Login now Smile

( " We are currently recruiting forum staffs " )
CYBERMIX | FORUM

Hello, Guest !

We would like to invite you to join our community.

Register & Login now Smile

( " We are currently recruiting forum staffs " )
. Login Register
CYBERMIX | FORUM

WE POST EVERYTHING YOU NEED


You are not connected. Please login or register

Like this topic? Then share our topic !

URL Direct
BBcode
HTML
Temperature Converter C++ Program

View previous topic View next topic Go down  Message [Page 1 of 1]

Post: #1Sun Jul 20, 2014 2:53 pm

Anonymous

Guest

Guest
Here is an example of a C++ program. Programmed by iKent

-------------------------------------------------------------
Code:

/*
For more C++ programs, visit www.cybermix.tk
Programmed by iKent
*/
#include <cstdlib>
#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
char from,to;
float k,c,f;
 cout<<"Temperature Converter By iKent" <<endl;
 cout<<"Choose a temperature to be converted" <<endl;
 cout<<"a. Celsius" <<endl;
 cout<<"b. Fahrenheit" <<endl;
 cout<<"c. Kelvin" <<endl;
cout<<"Choose: ";
cin>>from;
switch (from)
{ case 'a':
 cout<<"\n\nCelsius to..." <<endl;
cout<<"a. Fahrenheit" <<endl;
 cout<<"b. Kelvin" <<endl;
 cout<<"Choose: ";
 cin>>to;
 if (to=='a')
 {
 cout<<"Input celsius: " <<endl;
 cin>>c; f=(c*9/5)+32;
 cout<<"The temperature of Celsius to Fahrenheit is: " <<f;
 cout<<" F" <<endl;
}
if (to=='b')
 { cout<<"Input Degree Celsius: ";
cin>>c; k=c+273.15;
 cout<<"The temperature of Celsius to Kelvin is: " <<k;
 cout<<" K" <<endl;
 }
break;
case 'b':
cout<<"Fahreheit to..." <<endl;
 cout<<"a. Celsius" <<endl;
cout<<"b. Kelvin" <<endl;
 cout<<"Choose: ";
cin>>to;
 if (to=='a')
{
 cout<<"Input Degree Fahrenheit: " <<endl;
 cin>>f;
 c=(f-32)*5/9;
 cout<<"The temperature of Fahrenheit to Celsius is: " <<f;
 cout<<" C" <<endl;
 }
 if (to=='b')
 {
 cout<<"Input Fahrenheit: ";
 cin>>f;
 k=(f+459.67)*5/9;
 cout<<"The temperature of Fahrenheit to Kelvin is: " <<k;
 cout<<" K" <<endl;
}
 break;
 case 'c':
 cout<<"Kelvin to..." <<endl;
 cout<<"a. Celsius" <<endl;
 cout<<"b. Fahrenheit" <<endl;
 cout<<"Choose: ";
 cin>>to;
 if (to=='a')
 {
 cout<<"Input Kelvin: " <<endl;
 cin>>k;
 c=k-273.15;
cout<<"The temperature of Kelvin to Celsius is: " <<c;
 cout<<" C" <<endl;
}
 if (to=='b')
{
 cout<<"Input Kelvin: ";
cin>>k; f=(k*9/5)-459.67;
 cout<<"The temperature of Kelvin to Fahrenheit is: " <<f;
 cout<<"F"<<endl;
}
 break;
}
cout<<"\n\nDone converting!"<<endl;
 getch ();
 }

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum