Blog Kumpulan Tugas

Senin, 21 Desember 2015

Program Sederhana Konversi Suhu C++

#include <iostream>
#include <cstdlib>


using namespace std;

int main ()
{

    int ok;
    float x, a, b, c;

        cout << "-Konversi Suhu-" << endl;
        cout << endl;
        cout << "Pilih suhu yang akan dikonversi :" << endl;
        cout << "1. Celcius" <<endl;
        cout << "2. Reamur" <<endl;
        cout << "3. Fahrenheit" <<endl;
        cout << "4. Kelvin" <<endl;
        cout << endl;
        cout << "Jenis Suhu yang Dipilih : ";
        cin >> ok;

        if(ok==1)
        {
            cout << "Celcius \t  : ";
            cin >> x;
            a =  x*4/5;
            b = (9/5*x)+32;
            c = x+273;
            cout << "_____________________" << endl;
            cout << "Reamur \t\t  = " << a << endl;
            cout << "Fahrenheit \t  = " << b << endl;
            cout << "Kelvin \t\t  = " << a << endl;
       
        }
        if(ok==2)
        {
            cout << "Reamur \t  : ";
            cin >> x;
            a =  x*5/4;
            b = (9/4*x)+32;
            c = a+273;
            cout << "_____________________" << endl;
            cout << "Celcius \t\t  = " << a << endl;
            cout << "Fahrenheit \t  = " << b << endl;
            cout << "Kelvin \t\t  = " << a << endl;
       
        }   
        if(ok==3)
        {
            cout << "Fahrenheit \t  : ";
            cin >> x;
            a = (x-32)*5/9;
            b = (x-32)*4/9;
            c = a+273;
            cout << "_____________________" << endl;
            cout << "Celcius \t\t  = " << a << endl;
            cout << "Reamur \t  = " << b << endl;
            cout << "Kelvin \t\t  = " << a << endl;
       
        }
        if(ok==4)
        {
            cout << "Kelvin \t  : ";
            cin >> x;
            a = x-273;
            b = (x-273)*4/5;
            c = (a*9/5)+32;
            cout << "_____________________" << endl;
            cout << "Celcius \t\t  = " << a << endl;
            cout << "Reamur \t  = " << b << endl;
            cout << "Kelvin \t\t  = " << a << endl;
       
        }



return 0;
}
Tampilan Awal Program Konversi Suhu

Tampilan Hasil Konversi dari Celcius

Tampilan Hasil Konversi dari Reamur

Tampilan Hasil Konversi dari Fahrenheit

Tampilan Hasil Konversi dari Kelvin


Share:

0 komentar:

Posting Komentar

Diberdayakan oleh Blogger.

Blog Archive