Kamis, 13 Desember 2012

C++ < Listing Array >

#include<conio.h>
#include<iostream.h>
#include<stdio.h>
main()
{
int banyak,i,tipe[10],lama[10];
long int harga[10],tobar[10];
char lagi,kode[10],nmpenyewa[10][20],nmkamar[10][20],jenis[10][20];
awal:
clrscr();
cout<<"\t\t Data Penyewa Kamar Hotel SOALAGOGO"<<endl;
cout<<"Masukan Banyak Data : ";cin>>banyak;
for (i=1;i<=banyak;i++)
{
cout<<"Data Ke-"<<i<<endl;
cout<<"Nama Penyewa : ";cin>>nmpenyewa[i];
cout<<"Kode Kamar [A/B] : ";cin>>kode[i];
cout<<"Pilih Tipe Kamar [1/2] : ";cin>>tipe[i];
cout<<"Lama Sewa : ";cin>>lama[i];
cout<<endl;
if (kode[i]=='a'||kode[i]=='A')
{
                strcpy(nmkamar[i],"Melati");
   if (tipe[i]==1)
   {
                strcpy(jenis[i],"VIP");
      harga[i]=500000;
   }
   else
   {
                strcpy(jenis[i],"Reguler");
      harga[i]=350000;
   }
}
else
{
                strcpy(nmkamar[i],"Mawar");
   if (tipe[i]==1)
   {
                strcpy(jenis[i],"VIP");
      harga[i]=500000;
   }
   else
   {
                strcpy(jenis[i],"Reguler");
      harga[i]=350000;
   }
}
tobar[i]=lama[i]*harga[i];
}
//clrscr();
cout<<"\t\t\tHOTEL SOALAGOGO                                 "<<endl;
cout<<"========================================================"<<endl;
cout<<"No NamaPenyewa Nama Kamar Jenis Lama Sewa  Harga   Total"<<endl;
cout<<"========================================================"<<endl;
for (i=1;i<=banyak;i++)
{
cout<<i<<"  "<<nmpenyewa[i]<<"\t"<<nmkamar[i]<<"\t "<<jenis[i]<<"\t"<<lama[i]<<"\t"<<harga[i]<<"\t"<<tobar[i]<<endl;
}
cout<<"========================================================"<<endl;
cout<<endl;
cout<<"Ingin Input lagi [Y/T] : ";cin>>lagi;
if (lagi=='y'||lagi=='Y')
goto awal;
else
goto akhir;
getch();
akhir:
}

Tidak ada komentar:

Posting Komentar