Toko Buku Naura Borland C++ Tugas BSI


#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
judul()
{
cout<<"-----------------------------------------------------------------------"<<endl;
cout<<"\t\t\t         TOKO NAURA       "<<endl;
cout<<"======================================================================="<<endl<<endl;
}

long totalsub(long hrg,long jmlbeli)
{
return(hrg*jmlbeli);
}

long bayartotal(long ttlbyr,long sbttl)
{
return(ttlbyr+sbttl);
}

long kembali(long ubyr,long tbyr)
{
return(ubyr-tbyr);
}

main()
{
char nama_pembeli[30],lagi;
int j,a;
long total_bayar,uang_bayar,uang_kembali;

struct{
                char kode_barang[10],kode_ukuran[10],nama_barang[30],jenis_ukuran[20];
      int jumlah_beli,harga;
      long subtotal;
}beli[10];

awal:
clrscr();
total_bayar=0;

judul();
//INPUT
cout<<"Nama Pembeli            : ";cin>>nama_pembeli;
cout<<"Jumlah Data             : ";cin>>j;
for(a=1;a<=j;a++)
{
 cout<<"Data Ke -"<<a<<endl;
 cout<<"Kode Barang [G/H]       : ";cin>>beli[a].kode_barang;
 cout<<"Kode Ukuran [S/M/L]     : ";cin>>beli[a].kode_ukuran;
 cout<<"Jumlah Beli             : ";cin>>beli[a].jumlah_beli;
 if(!strcmp(beli[a].kode_barang,"G")||!strcmp(beli[a].kode_barang,"G"))
 {
  strcpy(beli[a].nama_barang,"Gamis");
  if(!strcmp(beli[a].kode_ukuran,"S")||!strcmp(beli[a].kode_ukuran,"S"))
  {
   strcpy(beli[a].jenis_ukuran,"S");
   beli[a].harga=160000;
  }
  else if(!strcmp(beli[a].kode_ukuran,"M")||!strcmp(beli[a].kode_ukuran,"M"))
  {
   strcpy(beli[a].jenis_ukuran,"M");
   beli[a].harga=1650000;
  }
  else if(!strcmp(beli[a].kode_ukuran,"L")||!strcmp(beli[a].kode_ukuran,"L"))
  {
   strcpy(beli[a].jenis_ukuran,"L");
   beli[a].harga=1700000;
  }
  else
  {
   strcpy(beli[a].jenis_ukuran,"SALAH MEMASUKAN KODE");
   beli[a].harga=0;
  }
 }
 else if(!strcmp(beli[a].kode_barang,"H")||!strcmp(beli[a].kode_barang,"H"))
 {
  strcpy(beli[a].nama_barang,"Hijab");
  if(!strcmp(beli[a].kode_ukuran,"S")||!strcmp(beli[a].kode_ukuran,"S"))
  {
   strcpy(beli[a].jenis_ukuran,"S");
   beli[a].harga=90000;
  }
  else if(!strcmp(beli[a].kode_ukuran,"M")||!strcmp(beli[a].kode_ukuran,"M"))
  {
   strcpy(beli[a].jenis_ukuran,"M");
   beli[a].harga=95000;
  }
  else if(!strcmp(beli[a].kode_ukuran,"L")||!strcmp(beli[a].kode_ukuran,"L"))
   {
   strcpy(beli[a].jenis_ukuran,"L");
   beli[a].harga=100000;
  }

  else
  {
   strcpy(beli[a].jenis_ukuran,"SALAH MEMASUKAN KODE");
   beli[a].harga=0;
  }
 }
 else
 {
  strcpy(beli[a].nama_barang,"SALAH MEMASUKAN KODE");
 }
cout<<endl;
}
cout<<endl<<endl;

clrscr();


//OUTPUT
judul();
cout<<"Nama Pembeli : "<<nama_pembeli<<endl;
cout<<endl;
cout<<"No  Kode       Nama Barang        Kode Ukuran   Jumlah Beli   Subtotal";
//     1   H            Hijab           S            1            90000
//     2   G            Gamis
cout<<endl;
for(a=1;a<=j;a++)
{
        cout<<setiosflags(ios::left)<<setw(4)<<a;
   cout<<setiosflags(ios::left)<<setw(11)<<beli[a].kode_barang;
   cout<<setiosflags(ios::left)<<setw(19)<<beli[a].nama_barang;
   cout<<setiosflags(ios::left)<<setw(14)<<beli[a].kode_ukuran;
   cout<<setiosflags(ios::left)<<setw(14)<<beli[a].jumlah_beli;
   beli[a].subtotal=totalsub(beli[a].harga,beli[a].jumlah_beli);
   cout<<setiosflags(ios::left)<<setw(5)<<beli[a].subtotal<<endl;
   total_bayar=bayartotal(total_bayar,beli[a].subtotal);
}
cout<<endl<<endl;
cout<<"Total Bayar  : "<<total_bayar<<endl;
cout<<"Uang Bayar   : ";cin>>uang_bayar;
uang_kembali=kembali(uang_bayar,total_bayar);
cout<<"Uang Kembali : "<<uang_kembali<<endl;
cout<<endl<<endl;

cout<<"Input Data Lagi [Y/T] : ";cin>>lagi;
if(lagi=='Y'||lagi=='y')
goto awal;
else
goto akhir;

getch();
akhir:
}

No comments:

Post a Comment

Pages