Laman

Selamat Datang Sahabat! Selamat ber-sharing Ilmu Komputer

Sabtu, 25 Februari 2012

Array ( Toko Baju)

#include <conio.h>
#include <stdio.h>
#include <iomanip.h>
#include <iostream.h>

main()
{
 int i,n,harga[5], total[5], totbay=0, jumbel[5], bayar, kembali, pot,tot;
 char kdbaju[10][5], uk[10][5], tpbaju[5][10], nama[20];
 clrscr();
 cout<<"=================================================="<<endl;
 cout<<"             TOKO BAJU SERBA SALAH "<<endl;
 cout<<" =KODE BAJU= =UKURAN=  =TYPE BAJU=   =HARGA="<<endl;
 cout<<"=================================================="<<endl;
 cout<<"    S21          S      FORMAL       Rp.60.000"<<endl;
 cout<<"    M22          M      ELEGAN       Rp.70.000"<<endl;
 cout<<"    X23          XL     SANTAI       Rp.80.000"<<endl;
 cout<<"    Z24         XXL     MODIS        Rp.90.000"<<endl;
 cout<<"=================================================="<<endl;
 cout<<endl;
 cout<<"Masukkan Nama Pelanggan : ";cin>>nama;
 cout<<"Masukkan Jumlah Transaksi : ";cin>>n;
 for(i=1; i<=n; i++)
 {
 cout<<"Transaksi Ke - "<<i<<endl;
 cout<<"Masukkan Kode Baju    : ";cin>>kdbaju[i];
 cout<<"Masukkan Jumlah Beli  : ";cin>>jumbel[i];
 if (!strcmp(kdbaju[i],"S21") || !strcmp(kdbaju[i],"s21"))
   {
    strcpy(uk[i],"S");
    strcpy(tpbaju[i],"FORMAL");
    harga[i]=60000;
   }
 else if (!strcmp(kdbaju[i],"M22") || !strcmp(kdbaju[i],"m22"))
   {
    strcpy(uk[i],"M");
    strcpy(tpbaju[i],"ELEGAN");
    harga[i]=70000;
   }
 else if (!strcmp(kdbaju[i],"X23") || !strcmp(kdbaju[i],"x23"))
   {
    strcpy(uk[i],"XL");
    strcpy(tpbaju[i],"SANTAI");
    harga[i]=80000;
   }
 else if (!strcmp(kdbaju[i],"Z24") || !strcmp(kdbaju[i],"z24"))
   {
    strcpy(uk[i],"XXL");
    strcpy(tpbaju[i],"MODIS");
    harga[i]=90000;
   }
 else
   {
    strcpy(uk[i],"Salah Kode");
    strcpy(tpbaju[i],"Salah Kode");
   }
 }
 clrscr();
 cout<<"===================================================="<<endl;
 cout<<"             TOKO BAJU SERBA SALAH "<<endl;
 cout<<"===================================================="<<endl;
 cout<<"No.  Kode   Ukuran   Tipe     Harga   Jumlah  Total"<<endl;
 cout<<"     Baju   Baju     Baju     Satuan  Beli          "<<endl;
 cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
 for(i=1; i<=n; i++)
 {
  cout<<setiosflags(ios::left)<<setw(5)<<i;
  cout<<setiosflags(ios::left)<<setw(8)<<kdbaju[i];
  cout<<setiosflags(ios::left)<<setw(8)<<uk[i];
  cout<<setiosflags(ios::left)<<setw(9)<<tpbaju[i];
  cout<<setiosflags(ios::left)<<setw(9)<<harga[i];
  cout<<setiosflags(ios::left)<<setw(6)<<jumbel[i];
  total[i]=harga[i]*jumbel[i];
  cout<<setiosflags(ios::left)<<setw(8)<<total[i]<<endl;
  totbay=totbay+total[i];
 }

 cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
 cout<<"Total Bayar         :Rp. "<<totbay<<endl;
 pot=totbay*0.02;
 cout<<"Potongan Harga      :Rp. "<<pot<<endl;
 cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
 tot=totbay-pot;
 cout<<"Total Pembayaran    :Rp. "<<tot<<endl;
 cout<<"Uang Bayar Anda     :Rp. ";cin>>bayar;
 kembali=bayar-tot;
 cout<<"Uang Kembalian Anda :Rp. "<<kembali<<endl;
 cout<<"================ TERIMA KASIH =================="<<endl;
 getch();
}

Check result Outputnya :

Tidak ada komentar:

Posting Komentar