Saturday, 23 April 2011

Tugas 6 c++

#include<constrea.h>
#include<stdio.h>
class sewa
{
public:
char kode[5],*judul,*pengarang;
int lama;
long int denda;
};
main()
{
char bulan[20],nm_peminjam[25],lagi[1];
int i,j;
float totbay;
totbay=0;
sewa buku[10];
atas:
clrscr();
cout<<" CITRA LIBRARY \n";
cout<<" PERUMNAS 2 Telp.(021)789567 \n";
cout<<"-----------------------------------------------------\n";
cout<<"Bulan : ";gets(bulan);
cout<<"Nama peminjam : ";gets(nm_peminjam);
cout<<"Masukkan jumlah data : ";cin>>j;
cout<<endl;
for(i=1;i<=j;i++)
{
cout<<"Data ke -"<<i<<endl;
cout<<"Kode buku [AADC/AAC/EIL] : ";cin>>buku[i].kode;
if(strcmpi(buku[i].kode,"AADC")==0)
{buku[i].judul="Ada Apa Dengan Cinta";
buku[i].pengarang="Mira Lesmana";}
else
if(strcmpi(buku[i].kode,"AAC")==0)
{buku[i].judul="Ayat-ayat Cinta";
buku[i].pengarang="Kang Abik";}
else
if(strcmpi(buku[i].kode,"EIL")==0)
{buku[i].judul="Eiffel I'm In Love";
buku[i].pengarang="Nia Dinata";}
cout<<"Judul buku : "<<buku[i].judul<<endl;
cout<<"Pengarang : "<<buku[i].pengarang<<endl;
cout<<"Lama pinjam : ";cin>>buku[i].lama;
if(buku[i].lama>7)
buku[i].denda=10000;
else
buku[i].denda=0;
cout<<endl;
}
clrscr();
cout<<" CITRA LIBRARY \n";
cout<<" PERUMNAS 2 Telp.(021)789567 \n";
cout<<"******************************************************\n";
cout<<"Bulan : "<<bulan<<endl;
cout<<"Nama peminjam : "<<nm_peminjam<<endl;
cout<<"------------------------------------------------------------------------\n";
cout<<"No. Kode Judul Pengarang Lama Denda \n";
cout<<" Buku Buku Sewa \n";
cout<<"------------------------------------------------------------------------\n";
for(i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i;
cout<<setiosflags(ios::left)<<setw(7)<<buku[i].kode;
cout<<setiosflags(ios::left)<<setw(12)<<buku[i].judul;
cout<<setiosflags(ios::left)<<setw(14)<<buku[i].pengarang;
cout<<setiosflags(ios::right)<<setw(10)<<buku[i].lama;
cout<<setiosflags(ios::right)<<setw(10)<<buku[i].denda<<endl;
totbay=totbay+buku[i].denda;
}
cout<<"------------------------------------------------------------------------\n";
cout<<"Total bayar : Rp."<<setprecision(10)<<totbay<<endl;
cout<<endl;
cout<<"Mau input lagi ? [Y/T] : ";cin>>lagi;
if(strcmpi(lagi,"Y")==0)
goto atas;
else
getch();
}
hasil runnya bisa di coba sendiri ya disini

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home