"CONTOH PERCABANGAN PROGRAM TOKO BUAH C++"
//FILE HEADER
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
//PEMBUKA
main()
{
//TIPE DATA
char nt[10],kk[20],kb,namakasir[20],namabuah[20],lagi;
int jb,harga,th,tb,ub,uk;
float diskon;
atas:
//INPUT
clrscr();
cout<<" Toko Buah Fruity Fresh "<<endl;
cout<<"--------------------------"<<endl;
cout<<"No Transaksi :";cin>>(nt);
cout<<"Kode Kasir [BM/RG/DR] :";cin>>(kk);
cout<<"--------------------------"<<endl;
cout<<"Kode Buah [A/K/S] :";cin>>(kb);
cout<<"jumlah Beli :";cin>>(jb);
//PROSES 1
if (strcmp(kk, "BM") == 0 || strcmp(kk, "bm") == 0)
{
strcpy(namakasir , "Bima");
}
else if (strcmp(kk, "RG") == 0 || strcmp(kk,"rg") == 0)
{
strcpy(namakasir , "Rangga");
}
else if (strcmp(kk, "DR") == 0 || strcmp(kk, "dr") == 0)
{
strcpy(namakasir , "Deri");
}
//PROSES 2
if(kb=='A' || kb=='a')
{
strcpy(namabuah, "Anggur");
harga=3000;
}
else if(kb=='K' || kb=='k')
{
strcpy(namabuah, "Kiwi");
harga=4000;
}
else if(kb=='S' || kb=='s')
{
strcpy(namabuah, "Sunkist");
harga=5000;
}
//OUTPUT
cout<<"---------------------------------------"<<endl;
cout<<" Struk Pembelian Buah "<<endl;
cout<<" Toko Buah Fruity Fresh "<<endl;
cout<<"***************************************"<<endl;
cout<<"No Transaksi :"<<nt<<endl;
cout<<"Nama Kasir :"<<namakasir<<endl;
cout<<"---------------------------------------"<<endl;
cout<<"Buah Yang Dibeli :"<<namabuah<<endl;
cout<<"Harga :"<<harga<<endl;
cout<<"Jumlah Beli :"<<jb<<endl;
cout<<"---------------------------------------"<<endl;
th=harga*jb;
cout<<" Total Harga:Rp"<<th<<endl;
if(jb>=5)
diskon=0.3*th;
else
diskon=0;
cout<<" Diskon 30%:Rp."<<diskon<<endl;
//TOTAL BAYAR
tb=th-diskon;
cout<<" Total Bayar:Rp"<<tb<<endl;
cout<<"======================================="<<endl;
cout<<" Uang Bayar:Rp.";cin>>ub;
uk=ub-tb;
cout<<" Uang Kembalian:Rp."<<uk<<endl;
cout<<"======================================="<<endl;
cout<<"Ingin Input Lagi [Y/T] :";cin>>lagi;
if (lagi=='Y' || lagi=='y')
goto atas;
else
{
clrscr();
cout<<"TERIMAKASIH ATAS KUNJUNGANNYA"<<endl;
}
//PENUTUP
getch();
}
Nb:Komen saja jika ada yang tidak bisa di Run,Insyaallah akan di bantu...
THANKS Semoga Bermanfaat
0 Komentar