SELAMAT DATANG

Translate Laman

Rabu, 23 Desember 2015

Coding Sederhana Kalkuloator C++


Berikut adalah coding sederhana C++ Program kalkulator, yang didalamya terdapat empat operasi inti dalam matematika diantaranya, penjumlahan, pengurangan, perkalian, dan pembagian,





#include <iostream.h>
#include <conio.h>
int main()
{
    int pil,a,b,hsl;
    cout<<"======================================================"<<endl;
    cout<<"=              ***PROGRAM KALKULATOR***              ="<<endl;
    cout<<"======================================================"<<endl;
    cout<<""<<endl;
    cout<<""<<endl;

    cout<<""<<endl;
    cout<<"==================================="<<endl;
    cout<<"= NAMA: M Arif Budiman            ="<<endl;
    cout<<"= NIM : 1595124003                ="<<endl;
    cout<<"= Prod: Sistem Informasi          ="<<endl;
    cout<<"==================================="<<endl;
    cout<<""<<endl;
    cout<<""<<endl;
    cout<<"======================================================="<<endl;
    cout<<"= 1.Penjumlahan 2.Pengurangan 3.Perkalian 4.Pembagian ="<<endl;
    cout<<"======================================================="<<endl;
    cout<<"masukan pilihan operasi (1..4):"<<endl;
    cout<<endl;
cin>>pil;
switch(pil)
{
case 1:
    cout<<"Penjumlahan"<<endl;
    cout<<"Masukan Bilangan 1 = ";cin>>a;
    cout<<"Masukan Bilangan 2 = ";cin>>b;
    hsl=a+b;
    cout<<"\nHasil Penjumlahan = "<<hsl<<endl;
break;
case 2:
    cout<<"Pengurangan"<<endl;
    cout<<"Masukan Bilangan 1 = ";cin>>a;
    cout<<"Masukan Bilangan 2 = ";cin>>b;
    hsl=a-b;
    cout<<"\nHasil Pengurangan = "<<hsl<<endl;
break;
case 3:
    cout<<"Perkalian"<<endl;
    cout<<"Masukan Bilangan 1 = ";cin>>a;
    cout<<"Masukan Bilangan 2 = ";cin>>b;
    hsl=a*b;
    cout<<"\nHasil Perkalian = "<<hsl<<endl;
break;
case 4:
    cout<<"Pembagian"<<endl;
    cout<<"Masukan Bilangan 1 = ";cin>>a;
    cout<<"Masukan Bilangan 2 = ";cin>>b;
    hsl=a/b;
    cout<<"\nHasil Pembagian = "<<hsl<<endl;
break;
default:
            cout<<"kode yang anda masukkan tidak ada"<<endl;
        }
getch();
}

0 komentar:

Posting Komentar

Kritik dan Saran Blog

Pengikut