Kalkulator C++



Script C++ Kalkulator Dengan Pernyataan Switch()

C++ Switch

Kali ini Saya akan membagikan sedikit ilmu Saya kepada kalian semua tentang Bahasa pemrograman C++. Materi yang akan dibahas kali ini adalah cara membuat program kalkulator dengan pernyataan switch menggunakan media compiler MinGW. Ok, langsung aja. Ini adalah script atau source code untuk membuat program kalkulator:

 Source Code:


#include <iostream>
#include <conio.h>
#include <stdio.h>
using namespace std;
int main()
{
                int cara;
                float angka1,angka2,hasil;
                mulai:
                cout<<"=========================================" <<endl; 
                cout<<"               KALKULATOR                " <<endl; 
                cout<<"               BISMOKO 14                " <<endl; 
                cout<<"=========================================" <<endl;
               
                cout<<"          Cara Yang Digunakan :          "<<endl;
                cout<<"========================================="<<endl;
                cout<<"1. Perkalian"<<endl;
                cout<<"2. Pembagian"<<endl;
                cout<<"3. Penjumlahan"<<endl;
                cout<<"4. Pengurangan"<<endl;
               
                cout<<"Cara Yang Digunakan : ";
                cin>>cara;
               
                switch(cara)
                {
                case 1:
                                cout<<"==============================="<<endl;
                                cout<<"           Perkalian           "<<endl;
                                cout<<"==============================="<<endl;
                                cout<<"Angka 1 : ";
                                cin>>angka1;
                                cout<<"Angka 2 : ";
                                cin>>angka2;
                               
                                hasil=angka1*angka2;
                               
                                cout<<"Hasil : "<<hasil<<endl;
                                cout<<"==============================="<<endl;
                                cout<<"Kunjungi bismoko14.blogspot.com"<<endl;
                                cout<<"==============================="<<endl;
                                break;
                case 2:
                                cout<<"==============================="<<endl;
                                cout<<"           Pembagian           "<<endl;
                                cout<<"==============================="<<endl;
                                cout<<"Angka 1 : ";
                                cin>>angka1;
                                cout<<"Angka 2 : ";
                                cin>>angka2;
                                hasil=angka1/angka2;
                                cout<<"Hasil : "<<hasil<<endl;
                                cout<<"==============================="<<endl;
                                cout<<"Kunjungi bismoko14.blogspot.com"<<endl;
                                cout<<"==============================="<<endl;
                                break;
                case 3:
                                cout<<"==============================="<<endl;
                                cout<<"          Penjumlahan          "<<endl;
                                cout<<"==============================="<<endl;
                                cout<<"Angka 1 : ";
                                cin>>angka1;
                                cout<<"Angka 2 : ";
                                cin>>angka2;
                                hasil=angka1+angka2;
                                cout<<"Hasil : "<<hasil<<endl;
                                cout<<"==============================="<<endl;
                                cout<<"Kunjungi bismoko14.blogspot.com"<<endl;
                                cout<<"==============================="<<endl;
                                break;
                case 4:
                                cout<<"==============================="<<endl;
                                cout<<"          Pengurangan          "<<endl;
                                cout<<"==============================="<<endl;
                                cout<<"Angka 1 : ";
                                cin>>angka1;
                                cout<<"Angka 2 : ";
                                cin>>angka2;
                                hasil=angka1-angka2;
                                cout<<"Hasil : "<<hasil<<endl;
                                cout<<"==============================="<<endl;
                                cout<<"Kunjungi bismoko14.blogspot.com"<<endl;
                                cout<<"==============================="<<endl;
                                break;
                default:
                                cout<<"Perintah Yang Dimasukkan Salah"<<endl;
                                break;
                }
                goto mulai;
                getch();
}

Ini hasil outputnya:


Kalkukator C++

Previous
Next Post »