Sunarya

Jumat, 03 Juni 2011

tugas 7

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

main()
{
char namap[50], namak[50], tgl[50], lanjut, ulangi;
char *namab[9];
long hasat[9], jumhar[9], totbar[9];
long bayar, kembali;
int jumbel[9], kode[9] = {1,2,3,4,5,6,7,8,9};
int x, y, z = 0;
clrscr();
cout<<"\n\n\t\tNama Kasir = ";gets(namak);
cout<<"\n\n\t\tTanggal Login [dd/mm/yyyy] = ";gets(tgl);
cout<<"\n\n\t\tKasir saat ini "<<namak;
cout<<"\n\n\n\t\tPress Anykey To Countinue . . .";
lanjut = getche();
if(lanjut == 'Q')
                goto program;
else
                goto program;
program:
clrscr();
cout<<"\n\t\tMasukan Nama Pembeli = ";gets(namap);
cout<<"\t\tJumlah Data = ";cin>>y;
totbar[y] = 0;
                for (x = 1; x <= y; x++)
                {
      cout<<"\n\t\t----------------------";
                cout<<"\n\t\tData Ke-"<<x;
      cout<<"\n\n\t\tInput Kode Barang = ";cin>>kode[x];
                if(kode[x] == 1)
                {
            namab[x] = "Buku";
            hasat[x] = 3500;
            }
         else if (kode[x] == 2)
            {
            namab[x] = "Pensil";
                hasat[x] = 2000;
            }
         else if (kode[x] == 3)
                {
            namab[x] = "Pulpen";
            hasat[x] = 2500;
            }
         else if (kode[x] == 4)
                {
            namab[x] = "Penggaris";
            hasat[x] = 2500;
            }
         else if (kode[x] == 5)
                {
            namab[x] = "Serutan";
            hasat[x] = 2000;
            }
         else if (kode[x] == 6)
                {
            namab[x] = "Penghapus";
            hasat[x] = 2000;
            }
                                                else if (kode[x] == 7)
                {
            namab[x] = "Tipe-x";
            hasat[x] = 4000;
            }
                                                else if (kode[x] == 8)
                {
            namab[x] = "Spidol";
            hasat[x] = 5000;
            }
                                                else if (kode[x] == 9)
            {
            namab[x] = "Stabilo";
                hasat[x] = 3000;
            }
         else if (kode[x] < 1 || kode[x] > 9)
                {
            clrscr();
                cout<<"\n\t\tKode yang ada Masukan Salah.\n";
            cout<<"\n\t\tPress Anykey to Continue . . .";
            ulangi = getche();
                if (ulangi == 'Q')
                                goto program;
               else
                  goto program;
            }
      cout<<"\t\tAnda Memilih = "<<namab[x];
      cout<<"\n\t\tDengan Harga Satuan = "<<hasat[x]<<endl;
      cout<<"\t\tInput Jumlah Beli = ";cin>>jumbel[x];
      jumhar[x] = hasat[x] * jumbel[x];
      totbar[y] = totbar[y] + hasat[x] * jumbel[x];
      }
cout<<"\n\t\tAda Kesalahan? [Y/T] ";
ulangi = getche();
                if (ulangi == 'Y' || ulangi == 'y')
      goto program;
bill:
clrscr();
cout<<"\nKasir = "<<namak;
cout<<setiosflags(ios::right)<<setw(55)<<"No faktur : FN-00"<<z<<endl;
cout<<"Pembeli = "<<namap;
cout<<setiosflags(ios::right)<<setw(46)<<"Tanggal = "<<tgl<<endl;
cout<<"--------------------------------------------------------------------------------";
cout<<" No         Nama              Harga             Qty                        Jumlah   \n";
cout<<"Unit       Barang            Satuan                               Harga    \n";
cout<<"--------------------------------------------------------------------------------";
   for(x = 1; x <= y; x++)
                {
      cout<<setiosflags(ios::left)<<setw(11)<<x;
      cout<<setiosflags(ios::left)<<setw(19)<<namab[x];
      cout<<setiosflags(ios::left)<<setw(19)<<hasat[x];
                                cout<<setiosflags(ios::left)<<setw(17)<<jumbel[x];
                                cout<<setiosflags(ios::left)<<setw(10)<<jumhar[x]<<endl;
      }
cout<<"--------------------------------------------------------------------------------\n";
cout<<setiosflags(ios::right)<<setw(66)<<"Total Bayar = "<<totbar[y]<<endl;
cout<<setiosflags(ios::right)<<setw(66)<<"Uang Bayar  = ";cin>>bayar;
                if(bayar >= totbar[y])
                                kembali = bayar - totbar[y];
   else
                goto bill;
cout<<setiosflags(ios::right)<<setw(66)<<"Kembalian   = "<<kembali<<endl;
cout<<"\n\n--------------------------------------------------------------------------------";
cout<<"\n\t\t\t\tTERIMA KASIH";
cout<<"\n--------------------------------------------------------------------------------";
cout<<"\n\nAnda Ingin Input Lagi? [Y/T] ";
ulangi = getche();
                if (ulangi == 'Y' || ulangi == 'y')
                {
      z++;
                goto program;
      }
   else
                goto akhir;
akhir:
getch();
}


Tidak ada komentar:

Posting Komentar