IP

Minggu, 29 April 2012

PROGRAM C++ EMPAT OPERASI DASAR MATEMATIKA

# include <iostream>
using namespace std ;
int main ()
{
                        char pilihan ;
                        cout << " Main Menu " ; cout << endl << endl ;
                        cout << " 1. Operasi Penjumlahan " ; cout << endl ;
                        cout << " 2. Operasi Pengurangan " ; cout << endl ;
                        cout << " 3. Operasi Perkalian " ; cout << endl ;
                        cout << " 4. Operasi Pembagian " ; cout << endl << endl ;
                        cout << " Masukkan Pilihan Anda : " ;
                        cin >> pilihan ;
                        switch ( pilihan ) {
                                 case '1' :
                                     float satu,dua,jumlah ;
                                     cout << endl ;
                                     cout << " Operasi Penjumlahan " ; cout << endl << endl ;
                                     cout << " Masukkan Nilai Pertama = " ;
                                     cin >> satu ;
                                     cout << " Masukkan Nilai Kedua = " ;
                                     cin >> dua ;
                                     jumlah = satu + dua ;
                                     cout << " Hasil Penjumlahan Dua Buah Bilangan Tersebut Adalah " << jumlah ;
                                     cout << endl << endl ;
                                     break ;
                                 case '2' :
                                     float tiga,empat,kurang ;
                                     cout << endl ;
                                     cout << " Operasi Pengurangan " ; cout << endl << endl ;
                                     cout << " Masukkan Nilai Pertama = " ;
                                     cin >> tiga ;
                                     cout << " Masukkan Nilai Kedua = " ;
                                     cin >> empat ;
                                     kurang = tiga - empat ;
                                     cout << " Hasil Pengurangan Dua Buah Bilangan Tersebut Adalah " << kurang ;
                                     cout << endl << endl ;
                                     break ;
                                 case '3' :
                                     float lima,enam,kali ;
                                     cout << endl ;
                                     cout << " Operasi Perkalian " ; cout << endl << endl ;
                                     cout << " Masukkan Nilai Pertama = " ;
                                     cin >> lima ;
                                     cout << " Masukkan Nilai Kedua = " ;
                                     cin >> enam ;
                                     kali = lima * enam ;
                                     cout << " Hasil Perkalian Dua Buah Bilangan Tersebut Adalah " << kali ;
                                     cout << endl << endl ;
                                     break ;
                                 case '4' :
                                     float tujuh,delapan,bagi ;
                                     cout << endl ;
                                     cout << " Operasi Pembagian " ; cout << endl << endl ;
                                     cout << " Masukkan Nilai Pertama = " ;
                                     cin >> tujuh ;
                                     cout << " Masukkan Nilai Kedua = " ;
                                     cin >> delapan ;
                                     bagi = tujuh / delapan ;
                                     cout << " Hasil Pembagian Dua Buah Bilangan Tersebut Adalah " << bagi ;
                                     cout << endl << endl ;
                                     break ;
                                     default :
                                     cout << " Anda Salah Piliha " ;
                                     cout << endl ;
                   }
                   return 0 ;
}

Output Program 1
 Output Program 2
 Output Program 3
 Output Program 4
 Output Program 5


0 komentar:

Posting Komentar

free counters