NESTED IF

Leave a comment

Inilah Contoh program Tiket Pesawat :

#include <conio.h>
#include <stdio.h>
#include <iostream.h>
main ()
{
char kode,kelas,lagi;
char napes[50];
long harga=0,tolbay,bayar,kembali;
float jumtik;
awal:
clrscr();
puts(“\tPROGRAM TIKET PESAWAT”);
puts(“\t  JAKARTA-MALAYSIA”);
puts(“=====================================”);
cout<<“Nama Pesawat :”<<endl;
cout<<“\t1. Merpati Airlines”<<endl;
cout<<“\t2. Garuda Indonesia”<<endl;
cout<<“\t3. Batavia Air”<<endl;
cout<<“Kode Pesawat [1/2/3] :”;cin>>kode;
cout<<“Kelas Pesawat :”<<endl;
cout<<“\t1. Executive “<<endl;
cout<<“\t2. Bisnis “<<endl;
cout<<“\t3. Ekonomi “<<endl;
cout<<“Pilih Kelas [1/2/3] :”;cin>>kelas;

if(kode==’1′)
{strcpy(napes,”MERPATI AIRLINES”);
if(kelas==’1′)harga=1500000;
else if(kelas==’2′)harga=900000;
else harga=700000;}

if(kode==’2′)
{strcpy(napes,”GARUDA INDONESIA”);
if(kelas==’1′)harga=1200000;
else if(kelas==’2′)harga=800000;
else harga=400000;}

if(kode==’3′)
{strcpy(napes,”BATAVIA AIR”);
if(kelas==’1′)harga=1000000;
else if(kelas==’2′)harga=700000;
else harga=300000;}

clrscr();
puts(“\tPROGRAM TIKET PESAWAT”);
puts(“\t  JAKARTA-MALAYSIA”);
puts(“=======================================”);
cout<<“Nama Pesawat\t:”<<napes<<endl;
cout<<“Harga Tiket\t:”<<harga<<endl;
cout<<“Jumlah Tiket\t:”;cin>>jumtik;
tolbay=harga*jumtik;
cout<<“Total Bayar\t:”<<tolbay<<endl;
cout<<“Uang Bayar\t:”;cin>>bayar;
kembali=bayar-tolbay;
cout<<“Kembali   \t:”<<kembali<<endl;

puts(“\t*****TERIMA KASIH*****\n”);
cout<<“Ingin Input Lagi? [Y/N]:”;cin>>lagi;

if(lagi==’Y’||lagi==’y’)
goto awal;
else
getch ();
}

 

Inilah hasil Outputnya :

#Semoga Bermanfaat 🙂 😛

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

me :)

Miss Moody

favorite song

Jam

Kalender ku

April 2017
M T W T F S S
« Oct    
 12
3456789
10111213141516
17181920212223
24252627282930

Masukkan alamat surat elektronik Anda untuk mengikuti blog ini dan menerima pemberitahuan tentang tulisan baru melalui surat elektronik.

Join 6 other followers

flag counter

%d bloggers like this: