Kalkulator Sederhana

#include <iostream>
/* 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) {
                int number;
                float a,b,hasil;
                cout<<"kalkulator"<<endl<<endl;
                cout<<"1. Penjumlahan"<<endl;
                cout<<"2. pengurangan"<<endl;
                cout<<"3. Perkalian"<<endl;
                cout<<"4. Pembagian"<<endl;
                cout<<"masukkan pilihan"<<endl;cin>>number;
switch (number){
case 1:
            cout<<endl<<"masukan angka pertama"<<endl;cin>>a;
                                cout<<"masukan angka kedua"<<endl;cin>>b;
                                hasil = a+b;
                                cout<<endl<<"hasil = "<<hasil;
                                break;
case 2:
           cout<<endl<<"masukan angka pertama"<<endl;cin>>a;
                                cout<<"masukan angka kedua"<<endl;cin>>b;
                                hasil = a-b;
                                cout<<endl<<"hasil = "<<hasil;
                                break; 
case 3:
          cout<<endl<<"masukan angka pertama"<<endl;cin>>a;
                                cout<<"masukan angka kedua"<<endl;cin>>b;
                                hasil = a*b;
                                cout<<endl<<"hasil = "<<hasil;
                                break;
case 4:
           cout<<endl<<"masukan angka pertama"<<endl;cin>>a;
                                cout<<"masukan angka kedua"<<endl;cin>>b;
                                hasil = a/b;
                                cout<<endl<<"hasil = "<<hasil;
                                break; 
default:
          cout<<endl<<"periksa kembali pilihan anda, karena pilihan anda tidak termasuk dalam menu";
                }

               
                return 0;
}

Share this

Related Posts

Previous
Next Post »