Contoh Program Rental VCD :
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
void main()
{
char yn, nama[100][30];
int x, i, trf[1000],jml[100], tot[100], byr[100], disk[100], no[100];
cout<<"\t\t --* PROGRAM RENTAL VCD *-- \t\t"<<endl;
cout<<"\t\t-------------------------"<<endl<<endl;
cout<<"Jumlah Data yang akan dimasukan : ";
cin>>x;
cout<<"------------------------------------"<<endl;
for(i=0;i<x;i++)
{
cout<<"Nama Peminjam "<<(i+1)<<"\t : ";
gets(nama[i]);
cout<<"Tarif Sewa /CD\t : Rp.";
cin>>trf[i];
cout<<"Jumlah CD\t : ";
cin>>jml[i];
cout<<endl;
tot[i] = trf[i]*jml[i];
if (jml[i]>7 || tot[i]>35000)
{
disk[i] = tot[i]*0.1;
cout<<"Diskon \t\t = Rp."<<disk[i]<<endl;
cout<<"------------------------------------"<<endl;
}
else
{
cout<<"Maaf Anda Tidak Mendapatkan Diskon."<<endl;
cout<<"------------------------------------"<<endl;
}
byr[i] = tot[i]-disk[i];
cout<<"Total Bayar \t = Rp."<<byr[i]<<endl;
cout<<"------------------------------------"<<endl<<endl;
}
cout<<"Tampilkan Data ? [Y/N]: ";
cin>>yn;
if (yn=='y'||yn=='Y')
cout<<"Data yang Anda Masukan adalah : "<<endl<<endl;
cout<<"----------------------------------------------------------------"<<endl;
cout<<"NO. Nama Peminjam Jumlah CD Total Harga Diskon Total Bayar"<<endl;
cout<<"----------------------------------------------------------------"<<endl;
for(i=0;i<x;i++)
{
no[i]=i+1;
cout<<no[i]<<" "<<nama[i]<<" "<<jml[i]<<" "<<tot[i]<<" "<<disk[i]<<" "<<byr[i]<<endl;
}
getch();
}
Tidak ada komentar:
Posting Komentar