#include <iostream>
using namespace std;
typedef struct kal
{
int memilih;
float bil1;
float bil2;
float hsl;
};
int main()
{
kal kulator;
cout<<"========== Program Kalkulator =========="<<endl;
cout<<"========== Eko Sutrisno ================"<<endl;
cout<<"1 Tambah"<<endl;
cout<<"2 Kurang"<<endl;
cout<<"3 Bagi"<<endl;
cout<<"4 Kali"<<endl;
cout<<"Pilihan anda : ";
cin>>kulator.memilih;
switch (kulator.memilih)
{
case 1:
cout<<"Masukkan bilangan 1 : "; cin>>kulator.bil1;
cout<<"Masukkan bilangan 2 : "; cin>>kulator.bil2;
kulator.hsl=kulator.bil1+kulator.bil2;
cout<<"Hasil : "<<kulator.hsl;
break;
case 2:
cout<<"Masukkan bilangan 1 : "; cin>>kulator.bil1;
cout<<"Masukkan bilangan 2 : "; cin>>kulator.bil2;
kulator.hsl=kulator.bil1-kulator.bil2;
cout<<"Hasil : "<<kulator.hsl;
break;
case 3:
cout<<"Masukkan bilangan 1 : "; cin>>kulator.bil1;
cout<<"Masukkan bilangan 2 : "; cin>>kulator.bil2;
kulator.hsl=kulator.bil1/kulator.bil2;
cout<<"Hasil : "<<kulator.hsl;
break;
case 4:
cout<<"Masukkan bilangan 1 : "; cin>>kulator.bil1;
cout<<"Masukkan bilangan 2 : "; cin>>kulator.bil2;
kulator.hsl=kulator.bil1*kulator.bil2;
cout<<"Hasil : "<<kulator.hsl;
break;
default:
cout<<"";
}
return 0;
}
Outpunya sebagai berikut:
Outputannya by eko sutrisno |
No comments:
Post a Comment