Senin, 13 Juni 2011

visual Program Penjualan sembako



//--------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#include "Unit2.h"
//--------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//--------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}
//--------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form2->Show();
}
//-------------------------------------------------------------------


//--------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//--------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "CSPIN"
#pragma resource "*.dfm"
TForm2 *Form2;
//--------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
        : TForm(Owner)
{
}
//--------------------------------------------------------------------
void __fastcall TForm2::ComboBox1Change(TObject *Sender)
{
if(ComboBox1->Text=="Indomie")
{
     Edit1->Text= 2000;
}
else if(ComboBox1->Text=="Sarimie")
{
     Edit1->Text= 1250;
}
else if(ComboBox1->Text=="Supermie")
{
     Edit1->Text= 1500;
}
else if(ComboBox1->Text=="Mie Sedap")
{
     Edit1->Text= 1750;
}
else
{
     Edit1->Text= 0;
}
}
//--------------------------------------------------------------------

void __fastcall TForm2::ComboBox2Change(TObject *Sender)
{
if(ComboBox2->Text=="Sirup ABC")
{
     Edit2->Text= 12000;
}
else if(ComboBox2->Text=="Sirup Marjan")
{
     Edit2->Text= 10000;
}
else
{
     Edit2->Text= 0;
}
}
//--------------------------------------------------------------------

void __fastcall TForm2::ComboBox3Change(TObject *Sender)
{
if(ComboBox3->Text=="Kecap Bango")
{
     Edit3->Text= 8000;
}
else if(ComboBox3->Text=="Kecap ABC")
{
     Edit3->Text= 5000;
}
else
{
     Edit3->Text= 0;
}
}
//--------------------------------------------------------------------

void __fastcall TForm2::ComboBox4Change(TObject *Sender)
{
 if(ComboBox4->Text=="Sabun Giv")
{
     Edit4->Text= 1500;
}
else if(ComboBox4->Text=="Sabun Lifeboy")
{
     Edit4->Text= 2000;
}
else if(ComboBox4->Text=="Sabun Lux")
{
     Edit4->Text= 1800;
}
else
{
     Edit4->Text= 0;
}
}
//--------------------------------------------------------------------

void __fastcall TForm2::ComboBox5Change(TObject *Sender)
{
if(ComboBox5->Text=="Sampo Clear")
{
     Edit5->Text= 400;
}
else if(ComboBox5->Text=="Sampo Pantene")
{
     Edit5->Text= 250;
}
else if(ComboBox5->Text=="Sampo Sunslik")
{
     Edit5->Text= 200;
}
else if(ComboBox5->Text=="Sampo Lifeboy")
{
     Edit5->Text= 300;
}
else if(ComboBox5->Text=="Sampo Zinc")
{
     Edit5->Text= 350;
}
else
{
     Edit5->Text= 0;
}
}
//--------------------------------------------------------------------

void __fastcall TForm2::Button2Click(TObject *Sender)
{
Close();       
}
//--------------------------------------------------------------------

void __fastcall TForm2::Button1Click(TObject *Sender)
{
float Jumlah;
Jumlah = StrToInt(Edit1->Text)*StrToInt(CSpinEdit1->Text)+
StrToInt(Edit2->Text)*StrToInt(CSpinEdit2->Text)+
StrToInt(Edit3->Text)*StrToInt(CSpinEdit3->Text)+
StrToInt(Edit4->Text)*StrToInt(CSpinEdit4->Text)+
StrToInt(Edit5->Text)*StrToInt(CSpinEdit5->Text);
Edit6->Text = Jumlah;       
}
//--------------------------------------------------------------------

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();
}