PROGRAM DASAR

Contoh Program Toko Pembelian Komputer dengan bahasa pemrograman C++
cekidot :

                                           Hasil gambar untuk c++
#include<iostream>
#include<sstream>
#include<stdlib.h>
#include<conio.h>

using namespace std;

string formatAngka(int angka, string perantara = ".") {
 stringstream ss; ss << angka;
 string output = ss.str();
 int inspost = output.length() - 3;
 while (inspost > 0) {
  output.insert(inspost, perantara);
  inspost -= 3;
 }
 return output;
}


int main(){
long int qty1=0,qty2=0,qty3=0,qty4=0,h1=0,h2=0,h3=0,h4=0,tot1=0,tot2=0,tot3=0,tot4=0,jum=0;
string na1,na2,na3,na4,np,kt,tgl,loop,akse1,akse2,akse3,akse4,z="",u1,u2,u3;

cout<<"TOKO KOMPUTER";
cout<<endl<<"Kode Transaksi     :";
getline(cin,kt);
cout<<"Tanggal            :";
getline(cin,tgl);
cout<<"Nama Pembeli       :";
getline(cin,np);
system("cls");

do{

a:

cout<<endl<<"Daftar Harga"<<endl;
cout<<"Keyboard   =   Rp. 100000"<<endl;
cout<<"Mouse      =   Rp. 80000"<<endl;
cout<<"Flashdisk  =   Rp. 90000"<<endl;
cout<<"HeadSet    =   Rp. 95000"<<endl;
cout<<"DIMOHON SAAT MENGETIKAN BARANG DI 'Nama Aksesoris' HARUS SESUAI DENGAN DAFTAR HARGA DIATAS"<<endl;
if(na1==""){
cout<<endl<<"Nama Aksesoris     :";
cin>>na1;
if(na1=="Keyboard"||na1=="keyboard"||na1=="KEYBOARD"||na1=="Mouse"||na1=="mouse"||na1=="MOUSE"||na1=="Flashdisk"||
na1=="flashdisk"||na1=="FLASHDISK"||na1=="HeadSet"||na1=="headset"||na1=="HEADSET")goto qty1;
else if(na1!="Keyboard"||na1!="keyboard"||na1!="KEYBOARD"||na1!="Mouse"||na1!="mouse"||na1!="MOUSE"||na1!="Flashdisk"||
na1!="flashdisk"||na1!="FLASHDISK"||na1!="HeadSet"||na1!="headset"||na1!="HEADSET"){
cout<<endl<<"Aksesoris Belum Tersedia";
getch();
system("cls");
na1="";
goto c;
}
qty1:
cout<<endl<<"Kuantitas :";
cin>>qty1;
}
else if(na1=="Keyboard"||na1=="keyboard"||na1=="KEYBOARD"||na1=="Mouse"||na1=="mouse"||na1=="MOUSE"||na1=="Flashdisk"||
na1=="flashdisk"||na1=="FLASHDISK"||na1=="HeadSet"||na1=="headset"||na1=="HEADSET"){


if(na2==""){
cout<<endl<<"Nama Aksesoris     :";
cin>>na2;
if(na2=="Keyboard"||na2=="keyboard"||na2=="KEYBOARD"||na2=="Mouse"||na2=="mouse"||na2=="MOUSE"||na2=="Flashdisk"||
na2=="flashdisk"||na2=="FLASHDISK"||na2=="HeadSet"||na2=="headset"||na2=="HEADSET")goto qty2;
else if(na2!="Keyboard"||na2!="keyboard"||na2!="KEYBOARD"||na2!="Mouse"||na2!="mouse"||na2!="MOUSE"||na2!="Flashdisk"||
na2!="flashdisk"||na2!="FLASHDISK"||na2!="HeadSet"||na2!="headset"||na2!="HEADSET"){
cout<<endl<<"Aksesoris Belum Tersedia";
getch();
system("cls");
na2="";
goto c;
}
qty2:
cout<<endl<<"Kuantitas :";
cin>>qty2;
}
else if(na2=="Keyboard"||na2=="keyboard"||na2=="KEYBOARD"||na2=="Mouse"||na2=="mouse"||na2=="MOUSE"||na2=="Flashdisk"||
na2=="flashdisk"||na2=="FLASHDISK"||na2=="HeadSet"||na2=="headset"||na2=="HEADSET"){

if(na3==""){
cout<<endl<<"Nama Aksesoris     :";
cin>>na3;
if(na3=="Keyboard"||na3=="keyboard"||na3=="KEYBOARD"||na3=="Mouse"||na3=="mouse"||na3=="MOUSE"||na3=="Flashdisk"||
na3=="flashdisk"||na3=="FLASHDISK"||na3=="HeadSet"||na3=="headset"||na3=="HEADSET")goto qty3;
else if(na3!="Keyboard"||na3!="keyboard"||na3!="KEYBOARD"||na3!="Mouse"||na3!="mouse"||na3!="MOUSE"||na3!="Flashdisk"||
na3!="flashdisk"||na3!="FLASHDISK"|na3!="HeadSet"||na3!="headset"||na3!="HEADSET"){
cout<<endl<<"Aksesoris Belum Tersedia";
getch();
system("cls");
na3="";
goto c;
}
qty3:
cout<<endl<<"Kuantitas :";
cin>>qty3;
}
else if(na3=="Keyboard"||na3=="keyboard"||na3=="KEYBOARD"||na3=="Mouse"||na3=="mouse"||na3=="MOUSE"||na3=="Flashdisk"||
na3=="flashdisk"||na3=="FLASHDISK"||na3=="HeadSet"||na3=="headset"||na3=="HEADSET"){

if(na4==""){
cout<<endl<<"Nama Aksesoris     :";
cin>>na4;
if(na4=="Keyboard"||na4=="keyboard"||na4=="KEYBOARD"||na4=="Mouse"||na4=="mouse"||na4=="MOUSE"||na4=="Flashdisk"||
na4=="flashdisk"||na4=="FLASHDISK"||na4=="HeadSet"||na4=="headset"||na4=="HEADSET")goto qty4;
else if(na4!="Keyboard"||na4!="keyboard"||na4!="KEYBOARD"||na4!="Mouse"||na4!="mouse"||na4!="MOUSE"||na4!="Flashdisk"||
na4!="flashdisk"||na4!="FLASHDISK"||na4!="HeadSet"||na4!="headset"||na4!="HEADSET"){
cout<<endl<<"Aksesoris Belum Tersedia";
getch();
system("cls");
na4="";
goto c;
}
qty4:
cout<<endl<<"Kuantitas :";
cin>>qty3;
}
else if(na4=="Keyboard"||na4=="keyboard"||na4=="KEYBOARD"||na4=="Mouse"||na4=="mouse"||na4=="MOUSE"||na4=="Flashdisk"||
na4=="flashdisk"||na4=="FLASHDISK"||na4=="HeadSet"||na4=="headset"||na4=="HEADSET"){
cout<<endl<<"Maaf Semua Jenis Aksesoris Sudah Anda Beli Semua"<<endl<<"Tekan Apa Saja Untuk Melihat Struk"<<endl<<endl;
getch();

goto lewat2;}

}
}
}

c:
cout<<endl<<"Tambah Aksesoris [Y/T] : ";
cin>>loop;
system("cls");
}
while(loop=="y" || loop=="Y");

lewat2:
if(loop=="t"||loop=="T"){cout<<"SEDANG DI PROSES, Tekan Apa Saja Untuk Melanjutkan";
getch();
}
system("cls");
if(na1=="Keyboard"||na1=="keyboard"||na1=="KEYBOARD")h1=100000;
if(na2=="Keyboard"||na2=="keyboard"||na2=="KEYBOARD")h2=100000;
if(na3=="Keyboard"||na3=="keyboard"||na3=="KEYBOARD")h3=100000;
if(na4=="Keyboard"||na4=="keyboard"||na4=="KEYBOARD")h4=100000;
if(na1=="Mouse"||na1=="mouse"||na1=="MOUSE")h1=80000;
if(na2=="Mouse"||na2=="mouse"||na2=="MOUSE")h2=80000;
if(na3=="Mouse"||na3=="mouse"||na3=="MOUSE")h3=80000;
if(na4=="Mouse"||na4=="mouse"||na4=="MOUSE")h4=80000;
if(na1=="Flashdisk"||na1=="flashdisk"||na1=="FLASHDISK")h1=90000;
if(na2=="Flashdisk"||na2=="flashdisk"||na2=="FLASHDISK")h2=90000;
if(na3=="Flashdisk"||na3=="flashdisk"||na3=="FLASHDISK")h3=90000;
if(na4=="Flashdisk"||na4=="flashdisk"||na4=="FLASHDISK")h4=90000;
if(na1=="Headset"||na1=="headset"||na1=="HEADSET")h1=95000;
if(na2=="Headset"||na2=="headset"||na2=="HEADSET")h2=95000;
if(na3=="Headset"||na3=="headset"||na3=="HEADSET")h3=95000;
if(na4=="Headset"||na4=="headset"||na4=="HEADSET")h4=95000;

tot1=h1*qty1;
tot2=h2*qty2;
tot3=h3*qty3;
tot4=h4*qty4;

cout<<"Kode Transaksi :"<<kt<<endl;
cout<<"Tanggal        :"<<tgl<<endl;
cout<<"Nama Aksesoris"<<" "<<"Kuantitas"<<" "<<"Harga"<<" "<<"Total"<<endl;
if(qty1!=0)cout<<na1<<" "<<qty1 <<" "<<formatAngka(h1) <<" Rp."<<formatAngka(tot1)<<endl;
if(qty2!=0)cout<<na2<<" "<<qty2 <<" "<<formatAngka(h2) <<" Rp."<<formatAngka(tot2)<<endl;
if(qty3!=0)cout<<na3<<" "<<qty3 <<" "<<formatAngka(h3) <<" Rp."<<formatAngka(tot3)<<endl;
if(qty4!=0)cout<<na4<<" "<<qty4 <<" "<<formatAngka(h4) <<" Rp."<<formatAngka(tot4)<<endl;
cout<<"________________________________________________________________________________";
jum=tot1+tot2+tot3+tot4;

cout<<"         Jumlah Yang Harus Dibayar : Rp. "<<formatAngka(jum)<<endl<<endl;

cout<<"Tekan Apa Saja Untuk Selesai";
getch();


system("cls");

cout<<"Terimakasih Telah Membeli Di Toko Ini:) "<<endl<<endl;

getch();
}

silahkan dicoba .

Comments

Archive

Contact Form

Send