Selasa, 07 Juni 2011

Program Penjualan Sembako

Ini adaah tugas pertama dari Pemrograman Terstruktur. Tugas 1 (midsemester)
 
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>

char nama[25],lg,tj[12][20],nomor;
float diskon,total,harga,tot,tot1;
int jumlah;

toko()
{
ats:
clrscr () ;
cout<<"\n            ~~~****** PROGRAM PENJUALAN SEMBAKO ******~~~";
 cout<<"\n";
 cout<<"\n";
 cout<<"\n                    -----| DAFTAR HARGA |-----";
 cout<<"\n";
 cout<<"           +========================================+\n";
 cout<<"           |  Nomor  :  Nama Barang    :    Harga   |\n";
 cout<<"           |    1    :     Mie         : Rp. 2.000  |\n";
 cout<<"           |    2    :     Sirup       : Rp.15.000  |\n";
 cout<<"           |    3    :     Kecap       : Rp. 8.000  |\n";
 cout<<"           |    4    :     Saos        : Rp. 6.000  |\n";
 cout<<"           |    5    :     Potato      : Rp. 3.000  |\n";
 cout<<"           |    6    :     Taro        : Rp. 2.000  |\n";
 cout<<"           +========================================+\n";
cout<<"Masukkan nomor :" ;
cin>>nomor ;
 if(nomor=='1')
 {
  cout<<"Mie"<<endl ;
  harga= 2000 ;
  cout<<"Harga 2000"<<endl;
 }
 if (nomor=='2')
 {
  cout<<"Sirup"<<endl ;
  harga=15000;
  cout<<"Harga 15.000"<<endl ;
 }
  if (nomor=='3')
 {
  cout<<"Kecap"<<endl ;
  harga=8000;
  cout<<"Harga 8.000"<<endl ;
 }
  if (nomor=='4')
 {
  cout<<"Saos"<<endl ;
  harga=6000;
  cout<<"Harga 6.000"<<endl ;
 }
  if (nomor=='5')
   {
  cout<<"Potato"<<endl ;
  harga=3000;
  cout<<"Harga 3.000"<<endl ;
 }
  if (nomor=='6')
 {
  cout<<"Taro"<<endl ;
  harga=2000;
  cout<<"Harga 2.000"<<endl ;
 }


/*cout<< endl ;
cout<<"Harga Barang :" ;
cin>>harga ; */
cout<< endl ;
cout<<"Jumlah Barang :" ;
cin>>jumlah ;
cout<< endl ;
tot=harga*jumlah ;
diskon=tot*0.1 ;
      if( jumlah>7)
          {
             total = tot-diskon ;
             cout<<"Diskon 10% ="<<diskon<<endl ;
             cout<< endl ;
             cout<<"Total Bayar anda = "<<total ;
             cout<< endl ;
             cout<< endl ;
             cout<< endl ;
            }
 else
          {
            cout<<"Maaf anda belum mendapatkan Diskon karena pembelian kurang dari 7"<<endl ;
            cout<< endl ;
            cout<<"Total Bayar Anda ="<<tot ;
                        cout<< endl ;

            cout<< endl ;
            cout<< endl ;
         cout<< endl ;
         cout<< endl ;


          }
cout <<"\n ";
cout <<"\n ";
cout <<"\n\t           Ingin Melakukan Transaksi Lagi[Y/N]= ";cin>>lg;
if (lg=='Y'||lg=='y')
goto ats;
else
getch();
}

void main()
{
int kd;
char lg;
menu:
clrscr();
 cout<<"                           PROGRAM PENJUALAN BARANG"<<endl ;
 cout<< endl ;
 cout<<"                              TOSERBA KIM-KIM"<<endl ;
 cout<<"                         JL.Gajah Mungkerep No.3030"<<endl ;
cout<<"\n";
 cout<<   "+========================================================================= + "<<endl;
 cout<<   "+= ======   ======   =          =       =       =      =        ======== = + "<<endl;
 cout<<   "+= =        =        =         =  =     = =   = =     =  =          =    = + "<<endl;
 cout<<   "+= ======   ======   =        ======    =   =   =    ======         =    = + "<<endl;
 cout<<   "+=      =   =        =       =      =   =       =   =      =        =    = + "<<endl;
 cout<<   "+= ======   ======   =====  =        =  =       =  =        =       =    = + "<<endl;
 cout<<   "+========================================================================= + "<<endl;
 cout<<      "        +========================================================== +         "<<endl;
 cout<<      "    += ===       =       ========   =       ==    =   ======  = +         "<<endl;
 cout<<      "    += =   =    =  =         =     =  =     = =   =   =       = +         "<<endl;
 cout<<      "    += =    =  ======        =    ======    =  =  =   =   ==  = +         "<<endl;
 cout<<      "    += =   =  =      =       =   =      =   =   = =   =    =  = +         "<<endl;
 cout<<      "    += ===   =        =      =  =        =  =    ==   ======  = +         "<<endl;
 cout<<      "    +========================================================== +         "<<endl;
 cout<< endl ;
 cout<< endl ;
 cout<< endl ;
 cout<<"           1. Masuk (IN)                     2. keluar (OUT)"<<endl ;
 cout<< endl ;
 cout<< endl ;
 cout<< endl ;
 cout<< endl ;
 cout<<"                          MASUKKAN 1 / 2 = ";cin>>kd;
switch(kd)
{
case 1: toko();break;
case 2: clrscr();cout<<"\n";cout<<"                            ANDA YAKIN AKAN KELUAR?   ";break;
default : cout<<"\n";
          cout<<"                           KODE ANDA SALAH";break;
}
cout<<"\n";
cout<<"                           KEMBALI KE MENU [Y/N] = ";cin>>lg;
if (lg=='Y'||lg=='y')
goto menu;
getch();
}

1 komentar:

  1. tambahkan pembahasan dan hasil eksekusi dari program yang dibuat...

    BalasHapus