scrib konversi suhu c++
#include <iostream.h>
#include <conio.h>
int main()
{
float S,C,K,F;
char pilih, ulang;
start:
clrscr();
cout<<"[[Teknik Informatika 2e Univ. Muhammadiyah Ponorogo 2011]]"<<endl;
cout<<" / -----------------------------------------------\\"<<endl;
cout<<" << Selamat Datang di Program Konversi Suhu >>"<<endl;
cout<<" \\------------------------------------------------/"<<endl;
cout<<""<<endl;
cout<<"Anda ingin menkonversi dalam apa ?"<<endl;
cout<<"_________________________________"<<endl;
cout<<""<<endl;
cout<<"1. celcius - fahrenheit"<<endl;
cout<<"2. celcius - kelvin"<<endl;
cout<<"3. fahrenheit - celcius "<<endl;
cout<<"4. fahrenheit - kelvin"<<endl;
cout<<"5. kelvin - celcius"<<endl;
cout<<"6. kelvin - fahrenheit"<<endl;
cout<<"_________________________________"<<endl;
cout<<""<<endl;
cout<<"pilihan anda:"; cin>>pilih;
cout<<"_________________________________"<<endl;
cout<<"Masukkan besar suhu yang ingin di Konversi "<<endl;
cout<<"Besar suhu:"; cin>>S;
cout<<"____________________________________________________ "<<endl;
cout<<""<<endl;
if (pilih=='1')
{
F=(S*(9/5))+32;
cout<<"jadi "<<S<<" Celcius = "<<F<<" Fahrenheit"<<endl;
}
else if (pilih=='2')
{
K=S+273.15;
cout<<"jadi "<<S<<" Celcius = "<<K<<" kelvin"<<endl;
}
else if (pilih=='3')
{
C=(5/9)*(S-32);
cout<<"jadi "<<S<<" Fahrenheit = "<<C<<" celcius"<<endl;
}
else if (pilih=='4')
{
K=(S + 459,67) / 1.8;
cout<<"jadi "<<S<<" Fahrenheit = "<<K<<" Kelvin"<<endl;
}
else if (pilih=='5')
{
C=S-273.15;
cout<<"jadi "<<S<<"Kelvin = "<<C<<" Celcius"<<endl;
}
else if (pilih=='6')
{
F=S * 1.8 - 459;
cout<<"jadi "<<S<<" kelvin = "<<F<<" Fahrenheit"<<endl;
}
else {
cout<<"Pilihan hanya ada 6"<<endl;
}
cout<<"___________________________________________________________"<<endl;
cout<<""<<endl;
cout<<""<<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;
}
getch ();
}
Komentar
Posting Komentar