Kamis, 30 Juni 2011

Mengkonfrensi suhu Celcius, Reamur dan Farenheit.


Programnya:

#include <iostream.h>
#include <conio.h>
int main(){

float C,R,K,F;
char pilih, ulang;
start:
clrscr();
cout<<" Selamat Datang di program konversi suhu"<<endl;
cout<<"Masukkan besar suhu (celcius) yang ingin di Konversi : "<<endl;
cout<<"-->";
cin>>C;

cout<<"Anda ingin mengkonversi "<<C<<" Celcius ke dalam apa ?"<<endl;
cout<<"1. Reamur "<<endl;
cout<<"2. Fahrenheit "<<endl;
cout<<"3. KElvin "<<endl;
cout<<"4. Reamur, Fahrenheit, dan Kelvin "<<endl;
cout<<"-->";
cin>>pilih;

if (pilih=='1'){
R=0.8*C;
cout<<"jadi "<<C<<" Celcius = "<<R<<" Reamur"<<endl;
}
else if (pilih=='2'){
F=(C*(9/5))+32;
cout<<"jadi "<<C<<" Celcius = "<<F<<" Fahrenheit"<<endl;
}
else if (pilih=='3'){
K=C+273;
cout<<"jadi "<<C<<" Celcius = "<<K<<" Kelvin"<<endl;
}
else if (pilih=='4'){
R=0.8*C; F=(C*(9/5))+32 ;K=C+273;
cout<<"jadi "<<C<<" Celcius = "<<R<<" Reamur, "<<F<<" Fahrenheit, "<<K<<" Kelvin"<<endl;
}
=else {
cout<<"Pilihan hanya ada 4"<<endl;
}
ask:
cout<<"Ulang kembali ? (y/n)"<<endl;
cin>>ulang;
if(ulang=='y'||ulang=='Y')
goto start;
else if (ulang=='n'||ulang=='Y')
return 0;
else {
goto ask;
}}
Aril Enggal's Web Developer

Morbi aliquam fringilla nisl. Pellentesque eleifend condimentum tellus, vel vulputate tortor malesuada sit amet. Aliquam vel vestibulum metus. Aenean ut mi aucto.

Tidak ada komentar:

Posting Komentar