Sunday, March 17, 2013

Temperature Conversion

#include<iostream>
#include<iomanip.h>
using namespace std;
int main()
{
    float x,temp,conv;
    start:
    cout<<setw(56)<<"TEMPERATURE CONVERSION MENU\n\n";
    cout<<setw(58)<<"********************************\n";
    cout<<"\n\n1.Fahrenheit to Celsius";
    cout<<"\n2.Celsius to Fahrenheit";
    cout<<"\n\nEnter your choice(1/2):";
    cin>>x;
    if(x==1)
    {
        cout<<"\nEnter temperature in Fahrenheit:";
        cin>>temp;
        conv=(temp-32)/1.8;
        cout<<"\nTemperature in Celsius:"<<conv;
    }
    else
    {
        cout<<"\nEnter temperature in Celsius:";
        cin>>temp;
        conv=(temp*1.8)+32;
        cout<<"\nTemperature in Fahrenheit:"<<conv;
    }
    char ch;
    cout<<"\n\nDo you want continue?(Press Y/N):";
    cin>>ch;
    if(ch=='Y' || ch=='y')
    goto start;
    return 0;
}

0 comments:

Post a Comment