Konversi Suhu

Soal :

1. Buatlah sebuah program konversi suhu,

Jawab :

1. Script Program :

#include <iostream.h>

#include <math.h>

#include <iomanip.h>

#include <conio.h>

void main()

{

double s,suhu;

char p,response;

do{

cout<<“Masukkan Nilai Suhu = “;

cin>>s;

cout<<endl;

cout<<“Pilih konversi berikut :\n”;

cout<<“A. Celcius ke Farenheit \n”;

cout<<“B. Farenheit ke Celcius \n”;

cout<<“C. Celcius ke Reamur \n”;

cout<<“D. Reamur ke Celcius \n”;

cout<<“E. Farenheit ke Reamur \n”;

cout<<“F. Reamur ke Farenheit \n\n”;

cout<<“Masukkan pilihan (A/B/C/D/E/F) = “;

cin>>p;

switch (p)

{

case ‘A’ :

suhu = 9.0/5.0 * s + 32.0;

cout<<“Temperatur “<<s<<” ‘C = “<<suhu<<“‘F”<<endl;

break;

case ‘B’ :

suhu = 5.0/9.0 * (s – 32.0);

cout<<“Temperatur “<<s<<” ‘F = “<<suhu<<“‘C”<<endl;

break;

case ‘C’ :

suhu = 4.0/5.0 * s;

cout<<“Temperatur “<<s<<” ‘C = “<<suhu<<“‘R”<<endl;

break;

case ‘D’ :

suhu = 5.0/4.0 * s;

cout<<“Temperatur “<<s<<” ‘R = “<<suhu<<“‘C”<<endl;

break;

case ‘E’ :

suhu = 4.0/5.0 * (s – 32.0);

cout<<“Temperatur “<<s<<” ‘F = “<<suhu<<“‘R”<<endl;

break;

case ‘F’ :

suhu = 5.0/4.0 * s + 32.0;

cout<<“Temperatur “<<s<<” ‘R = “<<suhu<<“‘F”<<endl;

break;

}

cout << endl << endl

<< “Pilih konversi lagi (Y/N)? “;

cin >> response;

}while (response==’y’ || response==’Y’);

cout << endl << endl << “Terima kasih telah menggunakan program kami.”<<endl;

}

One thought on “Konversi Suhu

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s