Membuat Kalkulator sederhana
Hai Guys!
Kali ini saya akan berbagi bagaimana cara membuat program kalkulator dengan Dev C++
#include <iostream>
#include <conio.h>
#include <cstdlib>
#include <math.h>
#include <cmath>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
float x,y,hasil,pilih;
system("cls");
cout<<"\t\t\t ============================\n"<<endl;
cout<<"\t\t\t --- KALKULATOR SEDERHANA ---"<<endl<<endl;
cout<<"\t\t\t ============================"<<endl;
kalkulator :
//operator perhitungan
cout<<"Operator Perhitungan:"<<endl;
string jumlah ="(1) penjumlahan (+)";
cout<<jumlah<<endl;
string pengurangan ="(2) pengurangan (-)";
cout<<pengurangan<<endl;
string perkalian ="(3) perkalian (*)";
cout<<perkalian<<endl;
string pembagian ="(4) pembagian (/)";
cout<<pembagian<<endl<<endl;
//mulai menghitung
cout<<"Masukan Angka A = ";
cin>>x;
cout<<"Masukan Angka B = ";
cin>>y;
int z;
cout<<"Pilih Operator Perhitungan= ";
cin>>z;
if(z==1)
{
hasil=x+y;
cout<<"Hasil penjumlahan = "<<hasil<<endl;
}
else if(z==2)
{
hasil=x-y;
cout<<"Hasil pengurangan = "<<hasil<<endl;
}
else if(z==3)
{
hasil=x*y;
cout<<"Hasil perkalian = "<<hasil<<endl;
}
else if(z==4)
{
hasil=x/y;
cout<<"Hasil pembagian = "<<hasil<<endl;
}
cout<<"================================================================================";
cout<<"Coba lagi [1]"<<endl;
cout<<"Keluar [2]"<<endl;
cout<<"================================================================================";
cout<<"Masukkan Pilihan : ";cin>>pilih;
if (pilih==1){
goto kalkulator;
}
if (pilih==2){
system("cls");
cout<<"================================================================================";
cout<<"\t\t Terima Kasih Telah Menggunakan Kalkulator Ini"<<endl;
cout<<"================================================================================";
cout<<"\t\t\t\tFathurrahman Masngudi"<<endl<<endl;
cout<<"\t\t\t Teknik Informatika"<<endl<<endl;
cout<<"\t\t\t\t 171552020531"<<endl;
cout<<"================================================================================"<<endl;
system("pause");
}
return 0;
}
Setelah di compile maka tampilannya akan seperti dibawah ini
Selamat Mencoba Guys
Kali ini saya akan berbagi bagaimana cara membuat program kalkulator dengan Dev C++
#include <iostream>
#include <conio.h>
#include <cstdlib>
#include <math.h>
#include <cmath>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
float x,y,hasil,pilih;
system("cls");
cout<<"\t\t\t ============================\n"<<endl;
cout<<"\t\t\t --- KALKULATOR SEDERHANA ---"<<endl<<endl;
cout<<"\t\t\t ============================"<<endl;
kalkulator :
//operator perhitungan
cout<<"Operator Perhitungan:"<<endl;
string jumlah ="(1) penjumlahan (+)";
cout<<jumlah<<endl;
string pengurangan ="(2) pengurangan (-)";
cout<<pengurangan<<endl;
string perkalian ="(3) perkalian (*)";
cout<<perkalian<<endl;
string pembagian ="(4) pembagian (/)";
cout<<pembagian<<endl<<endl;
//mulai menghitung
cout<<"Masukan Angka A = ";
cin>>x;
cout<<"Masukan Angka B = ";
cin>>y;
int z;
cout<<"Pilih Operator Perhitungan= ";
cin>>z;
if(z==1)
{
hasil=x+y;
cout<<"Hasil penjumlahan = "<<hasil<<endl;
}
else if(z==2)
{
hasil=x-y;
cout<<"Hasil pengurangan = "<<hasil<<endl;
}
else if(z==3)
{
hasil=x*y;
cout<<"Hasil perkalian = "<<hasil<<endl;
}
else if(z==4)
{
hasil=x/y;
cout<<"Hasil pembagian = "<<hasil<<endl;
}
cout<<"================================================================================";
cout<<"Coba lagi [1]"<<endl;
cout<<"Keluar [2]"<<endl;
cout<<"================================================================================";
cout<<"Masukkan Pilihan : ";cin>>pilih;
if (pilih==1){
goto kalkulator;
}
if (pilih==2){
system("cls");
cout<<"================================================================================";
cout<<"\t\t Terima Kasih Telah Menggunakan Kalkulator Ini"<<endl;
cout<<"================================================================================";
cout<<"\t\t\t\tFathurrahman Masngudi"<<endl<<endl;
cout<<"\t\t\t Teknik Informatika"<<endl<<endl;
cout<<"\t\t\t\t 171552020531"<<endl;
cout<<"================================================================================"<<endl;
system("pause");
}
return 0;
}
Setelah di compile maka tampilannya akan seperti dibawah ini
Selamat Mencoba Guys
Komentar
Posting Komentar