Codenya :
#include
<stdio.h>
#include
<conio.h>
#include
<iostream.h>
main()
{
//deklarasi variabel
char kode,kode_buku,lagi;
char*pilihan_novel;
float harga,jum_pembeli,total_bayar;
atas:
clrscr();
//input
cout<<" ---------------------------------------------------------"<<endl;
cout<<" |\t\t***** TOKO BUKU
ANANDA *****\t\t |"<<endl;
cout<<" |\t\t Jl.Gading Marpoyan\t\t |"<<endl;
cout<<"
---------------------------------------------------------"<<endl;
cout<<" 1.Laskar
Pelangi"<<pilihan_novel<<endl;
cout<<" 2.Sang
Pemimpi"<<pilihan_novel<<endl;
cout<<"
3.Edensor"<<pilihan_novel<<endl;
cout<<" Pilih Novel Yang anda
Beli [1,2,3] :
";cin>>kode_buku;
cout<<" Jumlah Pembelian buku
anda : ";cin>>jum_pembeli;
//output
clrscr();
cout<<"
---------------------------------------------------------"<<endl;
cout<<" |\t\t***** TOKO BUKU
ANANDA *****\t\t |"<<endl;
cout<<" |\t\t Jl.Gading Marpoyan\t\t |"<<endl;
cout<<"
---------------------------------------------------------"<<endl;
cout<<" Anda Membeli
Novel:"<<pilihan_novel;
switch(kode_buku)
{
case '1':
cout<< "Laskar Pelangi";
harga= 42000;
break;
case '2':
cout<< "Sang Pemimpi";
harga =44000;
break;
case '3':
cout<< "Edensor";
harga =46000;
break;
default:
cout<<"Kode tidak
terdaftar !!";
harga=0;
}
cout<<endl;
cout<<" Jumlah Pembelian buku
anda : "<<jum_pembeli;
cout<<" Harga Buku: Rp
"<<harga;
cout<<endl;
total_bayar = harga*jum_pembeli;
cout<<" Total Bayar: Rp
"<<total_bayar;
cout<<endl;
cout<<"
---------------------------------------------------------"<<endl;
cout<<" apakah anda mau input
lagi? [Y/T] :";cin>>lagi;
if(lagi == 'Y' || lagi =='y')
{
goto atas;
}
if (lagi == 'T' || lagi =='t')
{
goto selesai;
}
selesai:
cout<<endl;
cout<<" \t\t***** T E R I M A K
A S I H *****\t\t "<<endl;
cout<<" ---------------------------------------------------------"<<endl;
getch();
}
0 Komentar