LISTING PROGRAM
#include <cstdlib> |
#include <iostream> |
#include <math.h> |
using namespace std; |
class kalkulator{ |
public: |
float penjumlahan(); |
float pengurangan(); |
float perkalian(); |
float pembagian(); |
float akar(); |
float pangkat(); |
float pangkat_3(); |
|
private: |
float a,b,c,hasil; |
}; |
float kalkulator::penjumlahan(){ |
cout<< "\n===Penjumlahan==="<<endl; |
cout<<"Bilangan Pertama : ";cin>>a; |
cout<<"Bilangan Kedua : ";cin>>b; |
hasil=a+b; |
cout<<"Hasil : "<<hasil<<endl; |
} |
float kalkulator::pengurangan(){ |
cout<< "\n===Pengurangan==="<<endl; |
cout<<"Bilangan Pertama : ";cin>>a; |
cout<<"Bilangan Kedua : ";cin>>b; |
hasil=a-b; |
cout<<"Hasil : "<<hasil<<endl; |
} |
float kalkulator::perkalian(){ |
cout<< "\n===Perkalian==="<<endl; |
cout<<"Bilangan Pertama : ";cin>>a; |
cout<<"Bilangan Kedua : ";cin>>b; |
hasil=a*b; |
cout<<"Hasil : "<<hasil<<endl; |
} |
float kalkulator::pembagian(){ |
cout<< "\n===Pembagian==="<<endl; |
cout<<"Bilangan Pertama : ";cin>>a; |
cout<<"Bilangan Kedua : ";cin>>b; |
hasil=(a/b); |
cout<<"Hasil : "<<hasil<<endl; |
} |
|
float kalkulator::akar(){ |
cout<<"\n===Akar==="<<endl; |
cout<<"Masukkan Angka : "; |
cin>>a; |
hasil=sqrt(a); |
cout<<"Hasil : "<<hasil<<endl; |
} |
|
float kalkulator::pangkat(){ |
cout<<"\n===Pangkat==="<<endl; |
cout<<"Masukkan Bilangan : ";cin>>a; |
hasil=a*a; |
cout<< "Hasil : "<<hasil<<endl; |
} |
|
float kalkulator::pangkat_3(){ |
cout<<"\n===Pangkat_3==="<<endl; |
cout<<"Masukan Nilai : "; |
cin>>a; |
hasil=a*a*a; |
cout << "Hasil : "<<hasil<<endl; |
} |
|
int main() |
{ |
int m; |
kalkulator q; |
cout<<" =====================================\n"; |
cout<<" = BAYU PRASETYO <090182194> =\n "; |
cout<<"= =\n "; |
cout<<"= PROGRAM KALKULATOR SEDERHANA =\n "; |
cout<<"=====================================\n\n"; |
cout<<"1.Penjumlahan\n2.Pengurangan\n3.Perkalian\n4.Pembagian\n5.Akar\n6.Pangkat\n7.Pangkat_3\n\n\n"; |
cout<<"Masukkan Pilihan : ";cin>>m; |
if(m==1){q.penjumlahan(); |
}else if(m==2){q.pengurangan(); |
}else if(m==3){q.perkalian(); |
}else if(m==4){q.pembagian(); |
}else if(m==5){q.akar(); |
}else if(m==6){q.pangkat(); |
}else if(m==7){q.pangkat_3(); |
}else{ |
cout<<"Input Salah"<<endl; |
} |
system("PAUSE"); |
return EXIT_SUCCESS; |
} |