Tugas Kompilasi
TUGAS KOMPILASI
Nama : 1. Ghina Assyifa Kaltsum (13113709)
2. Nadia Faramita (16113277)
3. Nofri Ardiansyah (16113486)
4. Ratih Permatasari (17113301)
Nama : 1. Ghina Assyifa Kaltsum (13113709)
2. Nadia Faramita (16113277)
3. Nofri Ardiansyah (16113486)
4. Ratih Permatasari (17113301)
Kelas : 3KA19
Program Penjualan Barang Menggunakan C++
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main()
{
char nama[15],barang[15];
int kode,harga,jumbel,total;
clrscr();
puts("-------------------------------------");
puts(" TOKO BAJU ");
puts("-------------------------------------");
puts(" KODE BARANG ");
puts("-------------------------------------");
puts("1. Kain Sutra RP.100000 ");
puts("2. Kain Katun RP.50000 ");
puts("3.Kain Kombed RP.40000 ");
puts("4.Kain karded RP.20000 ");
puts("-------------------------------------");
puts("Input Nama Pembeli : ");cin>>nama;
puts("Input jenis Kain : ");cin>>kode;
cout<<"Input Jumlah Beli : ";cin>>jumbel;
switch(kode)
{
case 1:
strcpy(barang," Kain Sutra");
harga=100000;
break;
case 2:
puts("3.Kain Kombed RP.40000 ");
puts("4.Kain karded RP.20000 ");
puts("-------------------------------------");
puts("Input Nama Pembeli : ");cin>>nama;
puts("Input jenis Kain : ");cin>>kode;
cout<<"Input Jumlah Beli : ";cin>>jumbel;
switch(kode)
{
case 1:
strcpy(barang," Kain Sutra");
harga=100000;
break;
case 2:
strcpy(barang,"Kain Katun");
harga=50000;
break;
case 3:
strcpy(barang,"Kain Kombed");
harga=40000;
break;
case 4:
strcpy(barang,"Kain karded");
harga=20000;
break;
default:
strcpy(barang,"Anda Salah Kode");
harga=10;
harga=50000;
break;
case 3:
strcpy(barang,"Kain Kombed");
harga=40000;
break;
case 4:
strcpy(barang,"Kain karded");
harga=20000;
break;
default:
strcpy(barang,"Anda Salah Kode");
harga=10;
break;
}
total=jumbel*harga;
clrscr();
cout<<"==============================="<<endl;
cout<<" STRUK PENJUALAN "<<endl;
cout<<"==============================="<<endl;
cout<<"Nama Pembeli : "<<nama<<endl;
cout<<"Nama Barang : "<<barang<<endl;
cout<<"Harga Barang : "<<harga<<endl;
cout<<"Jumlah Barang : "<<jumbel<<endl;
cout<<"Total : "<<total;
getch();
}
}
total=jumbel*harga;
clrscr();
cout<<"==============================="<<endl;
cout<<" STRUK PENJUALAN "<<endl;
cout<<"==============================="<<endl;
cout<<"Nama Pembeli : "<<nama<<endl;
cout<<"Nama Barang : "<<barang<<endl;
cout<<"Harga Barang : "<<harga<<endl;
cout<<"Jumlah Barang : "<<jumbel<<endl;
cout<<"Total : "<<total;
getch();
}
ANALISIS LEKSIKAL
simbol : |#||" "| |>>| |<<| |{ }| |[ ]|
delimeter : |;| |()| |:|
nama variable : |nama| |barang| |kode| |harga| |jumbel| |total| |jumbel|
reserved word : |include| |conio.h| |iostream.h| |stdio.h| |main| |clrscr|
|puts| |cin| |cout| |switch| |case| |strcpy| |break| |default|
|getch| |endl|
Tipe Data : |char| |int|
number : 1 .. 4
operator : |=| | *|
delimeter : |;| |()| |:|
nama variable : |nama| |barang| |kode| |harga| |jumbel| |total| |jumbel|
reserved word : |include| |conio.h| |iostream.h| |stdio.h| |main| |clrscr|
|puts| |cin| |cout| |switch| |case| |strcpy| |break| |default|
|getch| |endl|
Tipe Data : |char| |int|
number : 1 .. 4
operator : |=| | *|
Daftar Pustaka : " http://pintarharati.blogspot.co.id/2013/07/program-penjualan-barang-menggunakan-c.html "
Komentar