#include <cstdlib>
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
class kalkulator{
public :
double menu ();
double kuadrat ();
double akar ();
double pangkat ();
double modulus ();
double logaritma();
double logsepuluh ();
double jumlah ();
double kurang ();
double kali ();
double bagi ();
private :
double a,b,c,hslJ,hslK,hslKL,hslB,hslKD,hslA,hslP,hslM,hslL,hslLS;
};
double kalkulator::menu(){
int pil;
cout<<"\t\t\t|========================================|"<<endl;
cout<<"\t\t\t| KALKULATOR SEDERHANA |"<<endl;
cout<<"\t\t\t|========================================|"<<endl<<endl;
cout<<"\t\t\t|========================================|"<<endl;
cout<<"\t\t\t| Nama: Deni Hermansyah |"<<endl;
cout<<"\t\t\t| NIM: 10018124 |"<<endl;
cout<<"\t\t\t| Kelas C |"<<endl;
cout<<"\t\t\t|========================================|"<<endl<<endl;
cout<<" MENU "<<endl;
cout<<"|-------------------------------|"<<endl;
cout<<"| |"<<endl;
cout<<"| silahkan pilih operator |"<<endl;
cout<<"| |"<<endl;
cout<<"|-------------------------------|"<<endl;
cout<<"|1.penjumlahan |"<<endl;
cout<<"|2.pengurangan |"<<endl;
cout<<"|3.perkalian |"<<endl;
cout<<"|4.pembagian |"<<endl;
cout<<"|5.kuadrat |"<<endl;
cout<<"|6.akar |"<<endl;
cout<<"|7.pangkat |"<<endl;
cout<<"|8.modulus |"<<endl;
cout<<"|9.logaritma |"<<endl;
cout<<"|10.logsepuluh |"<<endl;
cout<<"|-------------------------------|"<<endl<<endl;
cout<<"masukan salah satu pilihan : ";cin>>pil;
while(!((pil==1)||(pil==2)||(pil==3)||(pil==4)||(pil==5)||(pil==6)||(pil==7)||(pil==8)||(pil==9)||(pil==10)||(pil==11))){
cout<<"Pilihan yang anda masukkan salah!!!\nsilahkan coba lagi 1-7\n";
cout<<">>Pilih Salah Satu : ";cin>>pil;
}
switch(pil){
case 1 : jumlah();break;
case 2 : kurang ();break;
case 3 : kali (); break;
case 4 : bagi (); break;
case 5 : kuadrat ();break;
case 6 : akar ();break;
case 7 : pangkat ();break;
case 8 : modulus ();break;
case 9 : logaritma ();break;
case 10 : logsepuluh (); break;
}
}
double kalkulator::jumlah (){
cout<<"masukan angka :";cin>>a;
cout<<"masukan angka :";cin>>b;
hslJ=a+b;
cout<<"hasil :"<<hslJ<<endl<<endl<<endl;
}
double kalkulator::kurang(){
cout<<"masukan angka :";cin>>a;
cout<<"masukan angka :";cin>>b;
hslK=a-b;
cout<<"hasil :"<<hslK<<endl<<endl<<endl;
}
double kalkulator::kali(){
cout<<"masukan angka :";cin>>a;
cout<<"masukan angka :";cin>>b;
hslK=a*b;
cout<<"hasil :"<<hslK<<endl<<endl<<endl<<endl;
}
double kalkulator::bagi(){
cout<<"masukan angka :";cin>>a;
cout<<"masukan angka :";cin>>b;
hslB=a/b;
cout<<"hasil :"<<hslB<<endl<<endl<<endl;
}
double kalkulator::kuadrat(){
cout<<"masukan angka :";cin>>a;
hslKD=a*a;
cout<<"hasil :"<<hslKD<<endl<<endl<<endl;
}
double kalkulator::akar(){
cout<<"masukan nilai :";cin>>a;
hslA=sqrt (a);
cout<<"hasil :"<<hslA<<endl<<endl<<endl;
}
double kalkulator::pangkat(){
cout<<"masukan nilai :";cin>>a;
cout<<"masukan pangkat :";cin>>b;
hslP=pow(a,b);
cout<<"hasil :"<<hslP<<endl<<endl;
}
double kalkulator::modulus(){
cout<<"masukan angka :";cin>>a;
cout<<"masukan pembagi :";cin>>b;
hslM=fmod (a,b);
cout<<"hasil :"<<hslM<<endl<<endl;
}
double kalkulator::logaritma(){
cout<<"masukan nilai :";cin>>a;
hslL=log (a);
cout<<"hasil :"<<hslL<<endl<<endl<<endl;
}
double kalkulator::logsepuluh(){
cout<<"masukan nilai :";cin>>a;
hslLS=log10 (a);
cout<<"hasil :"<<hslLS<<endl<<endl<<endl;
}
int main(int argc, char *argv[])
{
kalkulator x;
x.menu();
system("PAUSE");
return EXIT_SUCCESS;
}
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
class kalkulator{
public :
double menu ();
double kuadrat ();
double akar ();
double pangkat ();
double modulus ();
double logaritma();
double logsepuluh ();
double jumlah ();
double kurang ();
double kali ();
double bagi ();
private :
double a,b,c,hslJ,hslK,hslKL,hslB,hslKD,hslA,hslP,hslM,hslL,hslLS;
};
double kalkulator::menu(){
int pil;
cout<<"\t\t\t|========================================|"<<endl;
cout<<"\t\t\t| KALKULATOR SEDERHANA |"<<endl;
cout<<"\t\t\t|========================================|"<<endl<<endl;
cout<<"\t\t\t|========================================|"<<endl;
cout<<"\t\t\t| Nama: Deni Hermansyah |"<<endl;
cout<<"\t\t\t| NIM: 10018124 |"<<endl;
cout<<"\t\t\t| Kelas C |"<<endl;
cout<<"\t\t\t|========================================|"<<endl<<endl;
cout<<" MENU "<<endl;
cout<<"|-------------------------------|"<<endl;
cout<<"| |"<<endl;
cout<<"| silahkan pilih operator |"<<endl;
cout<<"| |"<<endl;
cout<<"|-------------------------------|"<<endl;
cout<<"|1.penjumlahan |"<<endl;
cout<<"|2.pengurangan |"<<endl;
cout<<"|3.perkalian |"<<endl;
cout<<"|4.pembagian |"<<endl;
cout<<"|5.kuadrat |"<<endl;
cout<<"|6.akar |"<<endl;
cout<<"|7.pangkat |"<<endl;
cout<<"|8.modulus |"<<endl;
cout<<"|9.logaritma |"<<endl;
cout<<"|10.logsepuluh |"<<endl;
cout<<"|-------------------------------|"<<endl<<endl;
cout<<"masukan salah satu pilihan : ";cin>>pil;
while(!((pil==1)||(pil==2)||(pil==3)||(pil==4)||(pil==5)||(pil==6)||(pil==7)||(pil==8)||(pil==9)||(pil==10)||(pil==11))){
cout<<"Pilihan yang anda masukkan salah!!!\nsilahkan coba lagi 1-7\n";
cout<<">>Pilih Salah Satu : ";cin>>pil;
}
switch(pil){
case 1 : jumlah();break;
case 2 : kurang ();break;
case 3 : kali (); break;
case 4 : bagi (); break;
case 5 : kuadrat ();break;
case 6 : akar ();break;
case 7 : pangkat ();break;
case 8 : modulus ();break;
case 9 : logaritma ();break;
case 10 : logsepuluh (); break;
}
}
double kalkulator::jumlah (){
cout<<"masukan angka :";cin>>a;
cout<<"masukan angka :";cin>>b;
hslJ=a+b;
cout<<"hasil :"<<hslJ<<endl<<endl<<endl;
}
double kalkulator::kurang(){
cout<<"masukan angka :";cin>>a;
cout<<"masukan angka :";cin>>b;
hslK=a-b;
cout<<"hasil :"<<hslK<<endl<<endl<<endl;
}
double kalkulator::kali(){
cout<<"masukan angka :";cin>>a;
cout<<"masukan angka :";cin>>b;
hslK=a*b;
cout<<"hasil :"<<hslK<<endl<<endl<<endl<<endl;
}
double kalkulator::bagi(){
cout<<"masukan angka :";cin>>a;
cout<<"masukan angka :";cin>>b;
hslB=a/b;
cout<<"hasil :"<<hslB<<endl<<endl<<endl;
}
double kalkulator::kuadrat(){
cout<<"masukan angka :";cin>>a;
hslKD=a*a;
cout<<"hasil :"<<hslKD<<endl<<endl<<endl;
}
double kalkulator::akar(){
cout<<"masukan nilai :";cin>>a;
hslA=sqrt (a);
cout<<"hasil :"<<hslA<<endl<<endl<<endl;
}
double kalkulator::pangkat(){
cout<<"masukan nilai :";cin>>a;
cout<<"masukan pangkat :";cin>>b;
hslP=pow(a,b);
cout<<"hasil :"<<hslP<<endl<<endl;
}
double kalkulator::modulus(){
cout<<"masukan angka :";cin>>a;
cout<<"masukan pembagi :";cin>>b;
hslM=fmod (a,b);
cout<<"hasil :"<<hslM<<endl<<endl;
}
double kalkulator::logaritma(){
cout<<"masukan nilai :";cin>>a;
hslL=log (a);
cout<<"hasil :"<<hslL<<endl<<endl<<endl;
}
double kalkulator::logsepuluh(){
cout<<"masukan nilai :";cin>>a;
hslLS=log10 (a);
cout<<"hasil :"<<hslLS<<endl<<endl<<endl;
}
int main(int argc, char *argv[])
{
kalkulator x;
x.menu();
system("PAUSE");
return EXIT_SUCCESS;
}
0 komentar:
Posting Komentar