Kali ini saya mau bagi-bagi ilmu Pemrograman C++ tentang konversi suhu.
1. Celcius -> Reamur
2. Celcius -> Fahrenheit
3. Reamur -> Celcius
4. Reamur – > Fahrenheit
5. Fahrenheit -> Celcius
6. Fahrenheit -> Reamur
Berikut script programnya :
——————————————————————————
#include
#include
main()
{
ya :
float suhu, hasil;
int kode;
char pilihan;
cout << “ Konversi Suhu” << endl;
cout << “ =============” << endl;
cout << “==================================” << endl;
cout << “= 1. Celcius –> Reamur =” << endl;
cout << “= 2. Celcius –> Fahrenheit =” << endl;
cout << “= 3. Reamur –> Celcius =” << endl;
cout << “= 4. Reamur –> Fahrenheit =” << endl;
cout << “= 5. Fahrenheit –> Celcius =” << endl;
cout << “= 6. Fahrenheit –> Reamur =” << endl;
cout << “==================================” << endl;
cout << endl;
//ya :
cout << “Masukkan Kode Angka = “;
cin >> kode;
cout << endl;
switch(kode)
{
case 1:
cout << “Masukkan Suhu Dalam Celcius = “;
cin >> suhu ;
hasil = 0.8*suhu ;
cout << “Suhu Dalam Reamur = ” << hasil << endl;
break;
case 2:
cout << “Masukkan Suhu Dalam Celcius = “;
cin >> suhu ;
hasil = 1.8*suhu+32;
cout << “Suhu Dalam Fahrenheit = ” << hasil << endl;
break;
case 3:
cout << “Masukkan Suhu Dalam Reamur = “;
cin >> suhu ;
hasil = 1.25*suhu;
cout << “Suhu Dalam Celcius = ” << hasil << endl;
break;
case 4:
cout << “Masukkan Suhu Dalam Reamur = “;
cin >> suhu ;
hasil = 2.25*suhu+32;
cout << “Suhu Dalam Fahrenheit = ” << hasil << endl;
break;
case 5:
cout << “Masukkan Suhu Dalam Fahrenheit = “;
cin >> suhu ;
hasil = 5*(suhu-32)/9;
cout << “Suhu Dalam Celcius = ” << hasil << endl;
break;
case 6:
cout << “Masukkan Suhu Dalam Fahrenheit = “;
cin >> suhu ;
hasil = 4*(suhu-32)/9;
cout << “Suhu Dalam Reamur = ” << hasil << endl;
break;
default:
cout << “Kode angka salah” << endl;
break;
}
cout << endl;
cout << endl;
cout << “Apakah Ingin Mengulangi (Y/T)? “;
cin >> pilihan;
cout << endl;
masukan_salah:
switch(pilihan)
{
case ‘Y’:
system(“CLS”);
goto ya;
break;
case ‘T’:
//by johand vahrudin
break;
default:
cout << “Masukan Salah ” << endl << endl;
cout << “Apakah Ingin Mengulangi (Y/T)? “;
cin >> pilihan;
cout << endl;
goto masukan_salah;
break;
}
//getch();
}
———————————————————–
Jika di jalankan hasilnya seperti berikut :
Pemrograman C++ konversi suhu Celcius – Fahrenheit – Reamur
Author Adhitya
-
-
Home »
c++
,
teknikinformatika
,
tugaskuliah
»
Pemrograman C++ konversi suhu Celcius – Fahrenheit – Reamur