SOAL
Sebuah toko buku “ ILMU SEDIKIT” yang terletak di JL.tangerang barat No. 37 Telp (021) 94336189 menjual aneka buku sbb :
Kode jenis | Jenis | Kode buku | Buku | harga |
A || a | Cerita Anak | 1 | Comic | 9000 |
2 | Dongeng | 4000 | ||
B || b | Novel | 1 | Cinta | 25000 |
2 | Misteri | 20000 | ||
Lain-lain | Komputer | 1 | C++ | 25000 |
2 | Delphi | 30000 |
Total = harga x jumlah beli
SKRIPT
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main ()
{
char np[20],pt[20],kd,*jns,*nb,bk;
float hrg,jb,tot;
clrscr();
cout<<" TOKO BUKU \"SEDIKIT ILMU\""<<endl;
cout<<" Jl. Tangerang barat No37. Telp (021) 94336189"<<endl;
cout<<"--------------------------------------------"<<endl;
cout<<"Nama Pembeli : ";cin>>np;
cout<<"Nama Petugas : ";cin>>pt;
cout<<endl;
cout<<"----[ PILIHAN BUKU ]-----------------"<<endl;
cout<<" A. Cerita Anak"<<endl;
cout<<" 1. Comic Rp. 9000"<<endl;
cout<<" 2. Dongeng Rp. 4000"<<endl;
cout<<" B. Novel"<<endl;
cout<<" 1. Cinta Rp. 25000"<<endl;
cout<<" 2. Misteri Rp. 20000"<<endl;
cout<<" Komputer "<<endl;
cout<<" 1. C++ Rp. 25000"<<endl;
cout<<" 2. Delphi Rp. 30000"<<endl;
cout<<"-------------------------------------------"<<endl;
cout<<" Masukan Jenis Buku [A|B]:";cin>>kd;
cout<<" Masukan kode buku [1|2]:";cin>>bk;
if (kd=='A'||kd=='a')
{
jns="Cerita Anak";
if (bk=='1')
{
nb="Comic";
hrg=9000;
}
else
{
nb="dongeng";
hrg=4000;
}
}
else if (kd=='B'||kd=='b')
{
jns="Novel";
if (bk=='1')
{
nb="Cinta";
hrg=25000;
}
else
{
nb="Misteri";
hrg=20000;
}
}
else
{
jns="Komputer";
if (bk=='1')
{
nb="C++";
hrg=25000;
}
else
{
nb="Delphi";
hrg=30000;
}
}
cout<<endl;
cout<<" Jenis buku : "<<jns<<endl;
cout<<" Nama buku : "<<nb<<endl;
cout<<" Harga : "<<hrg<<endl;
cout<<" Jumlah Beli : ";cin>>jb;
tot=hrg*jb;
cout<<"----------------------------"<<endl;
cout<<" Total Bayar : Rp. "<<tot<<endl;
getch();
}
TAMPILAN HASIL SKRIPT
Tidak ada komentar:
Posting Komentar