0% found this document useful (0 votes)
20 views5 pages

#Include #Include Using Namespace Using Using Using

This document contains code for a C++ console application that simulates a shopping program. The program allows the user to select a product category, choose an item, enter the quantity, and then calculates the total, applies any discounts, and processes the payment. It has options for fashion, food & drinks, and other products. It calculates the total, checks if a discount applies based on the total, and then prompts the user to enter the amount paid to determine the change due. The program can be run multiple times to simulate repeat purchases.

Uploaded by

hilal fahrul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views5 pages

#Include #Include Using Namespace Using Using Using

This document contains code for a C++ console application that simulates a shopping program. The program allows the user to select a product category, choose an item, enter the quantity, and then calculates the total, applies any discounts, and processes the payment. It has options for fashion, food & drinks, and other products. It calculates the total, checks if a discount applies based on the total, and then prompts the user to enter the amount paid to determine the change due. The program can be run multiple times to simulate repeat purchases.

Uploaded by

hilal fahrul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

// TUGAS PROKOM.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"
#include "iostream"

using namespace std;

using std::cout;
using std::cin;
using std::endl;

int _tmain(int argc, _TCHAR* argv[])


{
int x,y,hrg1,jumbrg;
double diskon, total, totalbayar, bayar, sisa;
char brg1[20], jawab, kembali;

do
{
lagi:
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n";
cout<<" \n";
cout<<"--Selamat datang di Toko Bersama--\n";
cout<<" \n";
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n";
cout<<" \n";
cout<<"Barang : \n";
cout<<"1. Fashion\n";
cout<<"2. Makanan dan Minuman\n";
cout<<"3. Lainnya\n";
cout<<" Pilih jenis barang yang anda inginkan : "; cin>>x;

if (x==1)
{

cout<<"\n Fashion\n\n";
cout<<"1. Kaos\n";
cout<<"2. Kemeja\n";
cout<<"3. Celana Pendek\n";
cout<<"4. Rok\n";
cout<<"5. Jaket\n";
cout<<"\nPilih nama barang anda : ";
cin>>y;

if(y==1)
{
strcpy_s(brg1,"Kaos");
hrg1=25000;
}
if(y==2)
{
strcpy_s(brg1,"Kemeja");
hrg1=75000;
}
if(y==3)
{
strcpy_s(brg1,"Celana Pendek");
hrg1=15000;
}
if(y==4)
{
strcpy_s(brg1,"Rok");
hrg1=100000;
}
if(y==5)
{
strcpy_s(brg1,"Jaket");
hrg1=200000;
}
else
{
cout<<"\n";
}
cout<<"Nama : "<<brg1<<endl;
cout<<"Harga : Rp"<<hrg1<<endl;
cout<<"Jumlah barang : "; cin>>jumbrg;
cout<<"Apakah ada yang ingin dibeli lagi? [Y/T]\n";
cin>>jawab;
if (jawab=='Y'||jawab=='y')
goto lagi;
else if (jawab=='T'||jawab=='t')
goto tidak;
break;
tidak:

total=jumbrg*hrg1;
cout<<"Total belanja anda = Rp"<<total<<endl;
if (total>100000)
{
diskon=(total*10/100);
cout<<"\n\nSelamat anda mendapatkan diskon 10%\n";
totalbayar=total-diskon;
by:
cout<<" ** Anda harus bayar = Rp."<<totalbayar<<endl;
cout<<"Ada lagi?"<<endl;
cout<<"Lagi [Y/N] ? ";
cin>>jawab;
cout<<" ** Uang anda :";cin>>bayar;

}
else
{
diskon=(total*0/100);
totalbayar=total-diskon;
cout<<"\nTidak ada diskon\n";
cout<<"Anda harus bayar "<<totalbayar;
cout<<"\nUang anda : ";cin>>bayar;
}

if (bayar<totalbayar)
{
cout<<"uang anda tidak mencukupi"<<endl;
}
else {
sisa=bayar-totalbayar;
cout<<"\nSisa uang Rp"<<sisa;
}
}

else if (x==2)
{
cout<<"\n1. Roti";
cout<<"\n2. Mie Instan";
cout<<"\n3. Sirup";
cout<<"\nPilih nama barang anda : ";
cin>>y;

if(y==1)
{
strcpy_s(brg1,"Roti");
hrg1=14000;
}
if(y==2)
{
strcpy_s(brg1,"Mie Instan");
hrg1=3500;
}
if(y==3)
{
strcpy_s(brg1,"Sirup");
hrg1=10000;
}

else
{
cout<<"\n";
}
cout<<"Nama : "<<brg1<<endl;
cout<<"Harga : Rp"<<hrg1<<endl;
cout<<"Jumlah barang : "; cin>>jumbrg;

total=jumbrg*hrg1;
cout<<"Total belanja anda = Rp"<<total;
if (total>100000)
{
diskon=(total*7.5/100);
cout<<"\n\nSelamat anda mendapatkan diskon 7,5%\n";
totalbayar=total-diskon;
cout<<"Anda harus bayar = Rp.\n"<<totalbayar;
cout<<"\nUang anda : ";cin>>bayar;
sisa=bayar-totalbayar;
cout<<"\nSisa uang Rp"<<sisa;
}
else
{
diskon=(total*0/100);
totalbayar=total-diskon;
cout<<"\nTidak ada diskon\n";
cout<<"Anda harus bayar "<<totalbayar;
cout<<"\nUang anda : ";cin>>bayar;
}
if (bayar<totalbayar)
{
cout<<"uang anda tidak mencukupi"<<endl;
}
else {
sisa=bayar-totalbayar;
cout<<"\nSisa uang Rp"<<sisa;
}
}

else if (x==3)
{
cout<<"\n Lainnya\n\n";
cout<<"1. Paku\n";
cout<<"2. Palu\n";
cout<<"\nPilih nama barang anda : ";
cin>>y;

if(y==1)
{
strcpy_s(brg1,"Paku");
hrg1=2000;
}
else if(y==2)
{
strcpy_s(brg1,"Palu");
hrg1=30000;
}
else
{
cout<<"\n";
}
cout<<"Nama : "<<brg1<<endl;
cout<<"Harga : Rp"<<hrg1<<endl;
cout<<"Jumlah barang : "; cin>>jumbrg;

total=jumbrg*hrg1;
cout<<"Total belanja anda = Rp"<<total;
if (total>100000)
{
diskon=(total*5/100);
cout<<"\n\nSelamat anda mendapatkan diskon 5%\n";
totalbayar=total-diskon;
cout<<"Anda harus bayar = Rp.\n"<<totalbayar;
cout<<"\nUang anda : ";cin>>bayar;
sisa=bayar-totalbayar;
cout<<"\nSisa uang Rp"<<sisa;
}
else
{
diskon=(total*0/100);
totalbayar=total-diskon;
cout<<"\nTidak ada diskon\n";
cout<<"Anda harus bayar "<<totalbayar;
cout<<"\nUang anda : ";cin>>bayar;
}
if (bayar<totalbayar)
{
cout<<" uang anda tidak mencukupi "<<endl;
}
else
sisa=bayar-totalbayar;
cout<<"\nSisa uang Rp"<<sisa;
}
cout<<"Apakah ada yang ingin dibeli lagi? [Y/N] \n";
cin>>jawab;

}
while (jawab=='Y'||jawab=='y');
cin>>x;
return 0;
}

You might also like