0% found this document useful (0 votes)
36 views8 pages

Nama: Lutfiah Adifa NIM: 190170052 Unit: A2: Coding

The document contains code for a C++ program that allows a user to select food and drink items from a menu, calculates the total price, applies a discount based on the total, and displays the payment details. It includes the student's name and ID, menu options for selecting makanan (food), minuman (drink) and buah (fruit) with prices, use of switch statements, calculation of total price, discounts, and output of payment details.

Uploaded by

Difa Fangirl
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)
36 views8 pages

Nama: Lutfiah Adifa NIM: 190170052 Unit: A2: Coding

The document contains code for a C++ program that allows a user to select food and drink items from a menu, calculates the total price, applies a discount based on the total, and displays the payment details. It includes the student's name and ID, menu options for selecting makanan (food), minuman (drink) and buah (fruit) with prices, use of switch statements, calculation of total price, discounts, and output of payment details.

Uploaded by

Difa Fangirl
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/ 8

Nama : Lutfiah Adifa

NIM : 190170052
Unit : A2

Coding

#include<iostream>
using namespace std;
int main()
{

string namamakanan, namaminuman, namabuah;


int minuman, hargaminuman, makanan, hargamakanan, buah, hargabuah, total;
double diskon, totalpembayaran;

cout << endl;


cout<<"NAMA : Lutfiah Adifa " <<endl;
cout<<"NIM : 190170052 " <<endl;
cout<<"-----------------------" <<endl;
cout << endl;

cout<<"Pilih Makanan" <<endl;


cout<<"-----------------------" <<endl;
cout<<"[1] Martabak = Rp.5000" <<endl;
cout<<"[2] Mie Goreng = Rp.10000" <<endl;
cout<<"[3] Nasi Goreng = Rp.20000" <<endl;
cout<<"-----------------------" <<endl;
cout<<"Masukkan Angka Pilihan : ";
cin>>makanan;
cout<<endl;

switch(makanan)
{
case 1:
cout<<"Terpilih Martabak = Rp.5000"<<endl;
namamakanan = "Martabak";
hargamakanan = 5000;
break;

case 2:
cout<<"Terpilih Mie Goreng = Rp.10000"<<endl;
namamakanan = "Mie Goreng";
hargamakanan = 10000;
break;
case 3:
cout<<"Terpilih Nasi Goreng = Rp.20000"<<endl;
namamakanan = "Nasi Goreng";
hargamakanan = 20000;
break;
}
cout<<endl;

cout<<"Pilih Minuman" <<endl;


cout<<"-----------------------" <<endl;
cout<<"[1] Air Mineral = Rp.5000" <<endl;
cout<<"[2] Teh Hijau = Rp.10000" <<endl;
cout<<"[3] Jus = Rp.20000" <<endl;
cout<<"-----------------------" <<endl;
cout<<endl;
cout<<"Masukkan Angka Pilihan : ";
cin >> minuman;
cout<<endl;

switch(minuman)
{
case 1:
cout<<"Terpilih Air Mineral = Rp.5000"<<endl;
namaminuman = "Air Mineral";
hargaminuman = 5000;
break;

case 2:
cout<<"Terpilih Teh Hijau = Rp.10000"<<endl;
namaminuman = "Teh Hijau";
hargaminuman = 10000;
break;

case 3:
cout<<"Terpilih Jus = Rp.20000"<<endl;
namaminuman = "Jus";
hargaminuman = 20000;
break;
}
cout<<endl;

cout<<"Pilih Buah" <<endl;


cout<<"-----------------------" <<endl;
cout<<"[1] Pisang = Rp.7000" <<endl;
cout<<"[2] Mangga = Rp.10000" <<endl;
cout<<"[3] Naga = Rp.20000" <<endl;
cout<<"-----------------------" <<endl;
cout<<endl;
cout<<"Masukkan Angka Pilihan : ";
cin >>buah;
cout<<endl;

switch(buah)
{
case 1:
cout<<"Terpilih Pisang = Rp.7000"<<endl;
namabuah = "Pisang";
hargabuah = 7000;
break;

case 2:
cout<<"Terpilih Mangga = Rp.10000"<<endl;
namabuah = "Mangga";
hargabuah = 10000;
break;

case 3:
cout<<"Terpilih Naga = Rp.20000"<<endl;
namabuah = "Naga";
hargabuah = 20000;
break;
}
cout<<endl;

cout<<"Pembayaran" <<endl;
cout<<"---------------------------------" <<endl;
cout<< namamakanan <<" : Rp."<< hargamakanan <<endl;
cout<< namaminuman <<" : Rp."<< hargaminuman <<endl;
cout<< namabuah <<" : Rp."<< hargabuah <<endl;
cout<<"---------------------------------" <<endl;

total = hargamakanan + hargaminuman + hargabuah;

if (total >= 0 && total <= 15000)


{
diskon = total * 0.05;
}
else if (total >= 16000 && total <= 25000)
{
diskon = total * 0.07;
}
else if (total >= 26000 && total <= 30000)
{
diskon = total * 0.09;
}
else if (total >= 31000)
{
diskon = total * 0.1;
}

totalpembayaran = total - diskon;

cout<<"Total harga : Rp."<< total <<endl;


cout<<"Total diskon : Rp."<< diskon <<endl;
cout<<"Total bayar : Rp."<< totalpembayaran<<endl;

cout << endl;

return 0;
}
Hasil
FLOWCHART

MULAI

masukan pilihan
makanan

Case 1 Martabak = 5000

Case 2 Mie Goreng = 10000

Case Nasi Goreng = 20000

Terpilih
Makanan

masukan pilihan
minuman
iya

Case 1 Air Mineral = 5000

Case 2 Teh Hijau = 10000

Case Jus = 20000

Terpilih
Minuman
masukan pilihan
buah
Case 2 Mangga = 10000

Pisang = 7000
Case 1
Case 3 Naga = 20000

Terpilih Buah

Case 2 mangga = 10000 Break;

Total = hargamakanan + hargaminuman + hargabuah

Case Naga =20000 Break;

if (total >= 0 Diskon = 0.05 * total


&& total <=

else if (total >=


16000 && total <= Diskon = 0.07 * total
25000)

else if (total >=


26000 && total Diskon = 0.09 * total
<= 30000)

else if (total >= Diskon = 0.1 * total


31000)
totalpembayaran = total - diskon

Pembayaran
total harga =
total diskon =
total pembayaran =

selesai

You might also like