//Temprature Conversion Calculator
#include <iostream>
using namespace std; //Allows computer to output data
main() //main function begins
{
//declare variables
char option;
int temprature, farenheit, celsius;
//display program menu
cout << "\t\t\t\tTemprature converssion calculator\n\n" << endl;
cout << "To convert from Celsius to Farenheit, press, press \'f\':" << endl;
cout << "To convert from Farenheit to Celsius, press, press \'c\':" << endl;
cin >> option; //take input from the keyboard
if (option == 'f')
{
cout << "Enter value of temprature in Celsius......"; //display prompt for user
cin >> temprature; //input from keyboard
farenheit = (temprature * 9/5) + 32; //calculte the temprature in farenheit
cout << "\nTemprature in Farenheit is .............." << farenheit; //display the result on screen
}
else
{
cout << "Enter value of temprature in Farenheit......"; //display prompt for user
cin >> temprature; //input from keyboard
float celsius = (temprature - 32) *5/9; //calculte the temprature in celsius
cout << "\nTemprature in Farenheit is .............." << celsius; //display the result on screen
}
}//end of main function
#include <iostream>
using namespace std; //Allows computer to output data
main() //main function begins
{
//declare variables
char option;
int temprature, farenheit, celsius;
//display program menu
cout << "\t\t\t\tTemprature converssion calculator\n\n" << endl;
cout << "To convert from Celsius to Farenheit, press, press \'f\':" << endl;
cout << "To convert from Farenheit to Celsius, press, press \'c\':" << endl;
cin >> option; //take input from the keyboard
if (option == 'f')
{
cout << "Enter value of temprature in Celsius......"; //display prompt for user
cin >> temprature; //input from keyboard
farenheit = (temprature * 9/5) + 32; //calculte the temprature in farenheit
cout << "\nTemprature in Farenheit is .............." << farenheit; //display the result on screen
}
else
{
cout << "Enter value of temprature in Farenheit......"; //display prompt for user
cin >> temprature; //input from keyboard
float celsius = (temprature - 32) *5/9; //calculte the temprature in celsius
cout << "\nTemprature in Farenheit is .............." << celsius; //display the result on screen
}
}//end of main function
No comments:
Post a Comment