Selasa, 18 Agustus 2015

Program Kasir

Assalamualaikum bro....
nih saya kasih codingan aplikasi kasir, nah bedanya dengan aplikasi yang lain yaitu di program ini terdapat converter dari angka ke kata, penasaran??? nih codingnya

#include<stdio.h>
#include<conio.h>
#include<iostream>
using namespace std;

void satuan(int x) //satuan
{
if(x==1)cout<<" Satu ";
else if(x==2)cout<<" Dua ";
else if(x==3)cout<<" Tiga ";
else if(x==4)cout<<" Empat ";
else if(x==5)cout<<" Lima ";
else if(x==6)cout<<" Enam ";
else if(x==7)cout<<" Tujuh ";
else if(x==8)cout<<" Delapan ";
else if(x==9)cout<<" Sembilan ";
else if(x==10)cout<<" Sepuluh ";
else if(x==11)cout<<" Sebelas ";
}

void terbilang(long y)
{
if (y<=11) satuan(y);
else if ((y>11)&&(y<=19)) //belasan
{
terbilang(y%10);
cout<<"Belas";
}
else if ((y>=20)&&(y<=99)) //puluhan
{
terbilang(y/10);
cout<<"Puluh";
terbilang(y%10);
}
else if ((y>=100)&&(y<=199)) //seratus
{
cout<<" Seratus";
terbilang(y%100);
}
else if ((y>=200)&&(y<=999)) //Ratusan
{
terbilang(y/100);
cout<<"Ratus";
terbilang(y%100);
}
else if ((y>=1000)&&(y<=1999)) //seribu
{
cout<<" Seribu";
terbilang(y%1000);
}
else if ((y>=2000)&&(y<=999999)) //Ribuan
{
terbilang(y/1000);
cout<<" Ribu";
terbilang(y%1000);
}
else if ((y>=1000000)&&(y<=1999999)) //sejuta
{
cout<<" Sejuta";
terbilang(y%1000000);
}
else if ((y>=2000000)&&(y<=999999999)) //Jutaanan
{
terbilang(y/1000000);
cout<<" Juta";
terbilang(y%1000000);
}
else { cout<<"Error"; }
}

main()
{
unsigned long nilai;
int jp, produk;
char ukuran, lagi;
unsigned long total, harga, kembalian, pem;
do{
printf("\n\t++++ Aplikasi Kasir ++++\n");
printf("+--------------------------------------------------+\n");
printf("|NO \tNama Produk \tUkuran \t\tHarga      |\n");
printf("+--------------------------------------------------+\n");
printf("|1 \tSepatu \t\tL \t\t100.000    |\n");
printf("|  \t       \t\tM \t\t80.000     |\n");
printf("|  \t       \t\tS \t\t70.000     |\n");
printf("+--------------------------------------------------+\n");
printf("|2 \tSandal \t\tL \t\t30.000     |\n");
printf("|  \t       \t\tM \t\t25.000     |\n");
printf("|  \t       \t\tS \t\t15.000     |\n");
    printf("+--------------------------------------------------+\n");
printf("|3 \tTas \t\tL \t\t200.000    |\n");
printf("|  \t       \t\tM \t\t150.000    |\n");
printf("|  \t       \t\tS \t\t100.000    |\n");
printf("+--------------------------------------------------+\n");
printf("\nPilih Nomer Produk \t: "); scanf("%d",&produk);

switch(produk){
case 1:
printf("\nPilih Ukuran \t\t: "); scanf("%s",&ukuran);
switch(ukuran){
case 'l':
harga=100000; break;
case 'm' :
harga=80000; break;
case 's':
harga=70000; break;}
break;

case 2:
printf("\nPilih Ukuran \t\t: "); scanf("%s",&ukuran);
switch(ukuran){
case 'l':
harga=30000; break;
case 'm':
harga=25000; break;
case 's':
harga=15000; break;}
break;

case 3:
printf("\nPilih Ukuran \t\t: "); scanf("%s",&ukuran);
switch(ukuran){
case 'l':
harga=200000; break;
case 'm':
harga=150000; break;
case 's':
harga=100000; break;}
break;

}
//angka
printf("\nJumlah Produk \t\t: "); scanf("%d",&jp);
total=jp*harga; //total biaya
printf("\nTotal Biaya \t: Rp.%d ", total);
printf("\nPembayaran \t: Rp."); scanf("%d",&pem);
kembalian=pem-total; //kembalian
printf("Kembalian \t: Rp.%d ", kembalian);
printf("\n+--------------------------------------------------+\n");

//text
cout<<"\nJumlah Produk \t: ";
nilai=jp;
terbilang(nilai);

cout<<"\nTotal Biaya \t: "; //kembalian text
nilai=total;
terbilang(nilai);
cout<<" Rupiah";

cout<<"\nPembayaran \t: "; //kembalian text
nilai=pem;
terbilang(nilai);
cout<<" Rupiah";

cout<<"\nKembalian \t: "; //kembalian text
nilai=kembalian;
terbilang(nilai);
cout<<" Rupiah";
printf("\n+--------------------------------------------------+\n");

printf("\n\n Terimakasih.... :)");
printf("\n\nMenghitung lagi ? y/n  :"); scanf("%s",&lagi);
}while (lagi=='y');
}

//jangan lupa pada dieditin ya









Share:

0 komentar:

Posting Komentar

index

Popular Posts