Senin, 27 Oktober 2014

Contoh Sederhana Program C++ yang menggunakan Struktur Kendali,Operasi Aritmatika,Operasi Logika dan Do While


#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
void main ()
{
       int umur,orang,harga;
       string nama;
       char a;
       do
       {
       cout<<"==============================================================================="<<endl;
       cout<<"================================Selamat Datang================================="<<endl;
       cout<<"======================================Di======================================="<<endl;
       cout<<"==================================Pertandingan================================="<<endl;
       cout<<"============================BIG JAPAN pro-WRESTLING============================"<<endl;

       cout<<"Masukan Nama Anda          : ";cin>>nama;
       cout<<"Masukan Umur Anda          : ";cin>>umur;
       cout<<"Jumlah Tiket yang akan dibeli     : ";cin>>orang;
       cout<<"==============================================================================="<<endl;
       cout<<""<<endl;
       if (umur <= 15 )
       {
              cout<<"Maaf Umur Anda Tidak Mencukupi Untuk Menonton Pertandingan"<<endl;

       }
       else
              if ( umur >=15 && umur <=20)
       {
             
              cout<<"Selamat datang : "<<nama<<endl;
              cout<<"Pertandingan 1 : Ryuji Ito       vs Miyamoto Yuko"<<endl;
              cout<<"Pertandingan 2 : Hoshino Kankuro vs Isami Kodaka "<<endl;
              cout<<"Pertandingan 3 : Numazawa Jaki   vs Abdullah Kobayashi "<<endl;
              cout<<"Pertandingan 4 : Masada          vs Masato Inaba"<<endl;
              cout<<"Pertandingan 5 : Masashi Takeda  vs Daisuke Sekimoto"<<endl;
              cout<<"Pertandingan 6 : Jun kasai       vs Shadow WX"<<endl;
              cout<<"       Keterangan:"<<endl;
              cout<<"              Arena: Nippon Budokkan"<<endl;
              cout<<"              Hari : Senin"<<endl;

              cout<<""<<endl;
              cout<<"Total Bayar   : "<<100000*orang<<endl;
              cout<<"PPN 10%             : "<<orang*5000<<endl;
              cout<<"Total         : "<<(100000*orang)+orang*5000<<endl;
              cout<<"Bayar         : ";cin>>harga;
              cout<<"Kembali             : "<<harga-((100000*orang)+orang*5000)<<endl;

       }
       else
              if ( umur >= 21 && umur <= 35)
       {
              cout<<"Selamat Datang : "<<nama<<endl;
              cout<<"Pertandingan 1 : Masada          vs Daisuke Sekimoto"<<endl;
              cout<<"Pertandingan 2 : Masashi Takeda  vs Hoshino Kankuro"<<endl;
              cout<<"Pertandingan 3 : Miyamoto Yuko   vs Shadow WX"<<endl;
              cout<<"Pertandingan 4 : Ryuji Ito       vs Isami Kodaka "<<endl;
              cout<<"Pertandingan 5 : Numazawa Jaki   vs Masato Inaba"<<endl;
              cout<<"Pertandingan 6 : Jun Kasai       vs Abdullah Kobayashi"<<endl;
              cout<<"              Arena: Nippon Budokkan"<<endl;
              cout<<"              Hari : Rabu"<<endl;

              cout<<""<<endl;
              cout<<"Total Bayar   : "<<200000*orang<<endl;
              cout<<"PPN 10%             : "<<orang*5000<<endl;
              cout<<"Total         : "<<(200000*orang)+orang*5000<<endl;
              cout<<"Bayar         : ";cin>>harga;
              cout<<"Kembali             : "<<harga-((200000*orang)+orang*5000)<<endl;

       }
       else
              if ( umur >= 36 && umur <= 50 )
       {
              cout<<"Selamat Datang : "<<nama<<endl;
              cout<<"Pertandingan 1 : Miyamoto Yuko    vs Isami Kodaka  "<<endl;
              cout<<"Pertandingan 2 : Numazawa Jaki    vs Hoshino Kankuro "<<endl;
              cout<<"Pertandingan 3 : Daisuke Sekimoto vs Masashi Takeda"<<endl;
              cout<<"Pertandingan 4 : Masada           vs Jun Kasai"<<endl;
              cout<<"Pertandingan 5 : Shadow WX        vs Abdullah Kobayashi"<<endl;
              cout<<"Pertandingan 6 : Ryuji Ito        vs Masato Inaba "<<endl;
              cout<<"              Arena: Nippon Budokkan"<<endl;
              cout<<"              Hari : Jumat"<<endl;

              cout<<""<<endl;
              cout<<"Total Bayar   : "<<300000*orang<<endl;
              cout<<"PPN 10%             : "<<orang*5000<<endl;
              cout<<"Total         : "<<(300000*orang)+orang*5000<<endl;
              cout<<"Bayar         : ";cin>>harga;
              cout<<"Kembali             : "<<harga-((300000*orang)+orang*5000)<<endl;
       }
       else if( umur >50)
       {
              cout<<"Maaf Anda Tidak Boleh Masuk Karena Faktor Usia"<<endl;
       }
      
       cout<<"==============================================================================="<<endl;
       cout<<"==================================Terima Kasih================================="<<endl;
       cout<<"=========================Selamat Menyaksikan Pertandingan======================"<<endl;
       cout<<"Apakah Anda Ingin Mengulang Program (y/t)? : ";cin>>a;
       }while (nama,umur,orang,harga,a == 'y');
              _getch();
}
=============================================================================================




Tidak ada komentar:

Posting Komentar