Kamis, 15 April 2010

Program Penjualan Barang

#include <iostream>
#include <conio>
#include <iomanip>

void barang()
{cout<<"Daftar Barang Dagangan :"<<endl;
 cout<<"\t1.Sepatu Adidas"<<endl;
 cout<<"\t2.Sepatu Nike"<<endl;
 cout<<"\t3.Sepatu Lotto"<<endl;
 cout<<"\t4.Kaos Man.United"<<endl;
 cout<<"\t5.Kaos Barcelona"<<endl;
 cout<<"\t6.Kaos Chelsea"<<endl;
 cout<<"\t7.Bola Nike"<<endl;
 cout<<"\t8.Bola Adidas"<<endl;
 cout<<"\t9.Bola Diadora"<<endl<<endl;}
void totyar()
{cout<<"=============================="<<endl;
cout<<"       Daftar Penjualan"<<endl;
cout<<"=============================="<<endl;
cout<<" No Nama Barang         Harga     "<<endl;
cout<<"=============================="<<endl;}
long potongan(int n,long pot,long bayar)
{if (n>=5)
    return pot=0.05*bayar;
else return pot=0;}

main(){
struct{
        long harga;
      char sptu[25];
      int pilih,pilih1,pilih2,pilih3,spat;}
      brg[8];
int i,n,a;
char jawab;
long bayar,total,pot;
depan:
cout<<"Masukkan Jumlah Barang : ";cin>>n;
bayar=0;
clrscr();
barang();
for(i=1;i<=n;i++){
ulang:
cout<<"Masukkan pilihan : ";cin>>brg[i].pilih;
switch (brg[i].pilih)
       {case 1:
              strcpy(brg[i].sptu,"Sepatu Adidas");
            brg[i].harga=100000;
       break;
       case 2:
               strcpy(brg[i].sptu,"Sepatu Nike");
            brg[i].harga=120000;
       break;
       case 3:
               strcpy(brg[i].sptu,"Sepatu Lotto");
            brg[i].harga=130000;
       break;
       case 4:
              strcpy(brg[i].sptu,"Kaos Man.United");
            brg[i].harga=50000;
       break;
       case 5:
               strcpy(brg[i].sptu,"Kaos Barcelona");
            brg[i].harga=45000;
       break;
       case 6:
               strcpy(brg[i].sptu,"Kaos Chelsea");
            brg[i].harga=40000;
       break;
       case 7:
              strcpy(brg[i].sptu,"Bola Nike");
            brg[i].harga=70000;
       break;
       case 8:
               strcpy(brg[i].sptu,"Bola Adidas");
            brg[i].harga=65000;
       break;
       case 9:
               strcpy(brg[i].sptu,"Bola Diadora");
            brg[i].harga=60000;
       break;
       default:cout<<"Anda Salah Input"<<endl<<endl;goto ulang;break;}
bayar=bayar+brg[i].harga;
cout<<""<<i<<"."<<brg[i].sptu<<endl<<endl;}

total=bayar-potongan(n,pot,bayar);

totyar();
for(i=1;i<=n;i++){
cout<<setiosflags(ios::right)<<setw(3)<<i<<" ";
cout<<setiosflags(ios::left)<<setw(15)<<brg[i].sptu;
cout<<setiosflags(ios::right)<<setw(10)<<brg[i].harga<<endl;}
cout<<"=============================="<<endl;
cout<<"Total                : "<<bayar<<endl;
cout<<"Potongan             : "<<potongan(n,pot,bayar)<<endl;
cout<<"Total                : "<<total<<endl;
cout<<"=============================="<<endl;
cout<<endl;
cout<<"Ingin Mengulangi Lagi [Y/T] : ";cin>>jawab;
clrscr();
switch (jawab)
{case 'Y','y':
    goto depan;
    break;
 case 'T','t':
    gotoxy(4,1);cout<<"Tekan Enter Untuk Keluar "<<endl;
   break;
 default:cout<<"Anda Salah Input!!!"<<endl;
     break;}
getch();}

Tidak ada komentar:

Posting Komentar