Last active
November 9, 2018 04:18
-
-
Save andrinur13/bfa8e5e6c6ed39eabb074159da19854a to your computer and use it in GitHub Desktop.
soal postest 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdlib> | |
using namespace std; | |
int main(int argc, char const *argv[]) | |
{ | |
/* | |
Andri Nur Hidayatulloh | |
1800018190 | |
Kelas D | |
Slot Praktikum Selasa 7.30 Lab Jaringan A | |
*/ | |
string user, key; | |
string userAuth = "user123"; | |
string keyAuth = "qwerty123"; | |
int umur, pilihan, harga, diskon, total, uang, jumlah; | |
cout << "=== PROGRAM KASIR WARUNG MAKAN ===" << endl << endl; | |
cout << "User : "; getline(cin, user); | |
cout << "Key : "; getline(cin, key); | |
cout << "Umur : "; cin >> umur; | |
system("cls"); | |
if(umur > 12) { | |
cout << "==== PROGRAM KASIR WARUNG MAKAN ====" << endl; | |
cout << "=========== MENU PILIHAN ===========" << endl; | |
cout << "1. Nasi Goreng Pedas --- Rp. 12.000" << endl; | |
cout << "2. Nasi Rames ---------- Rp. 9.000" << endl; | |
cout << "3. Pecel Lele ---------- Rp. 13.000" << endl; | |
cout << "4. Ayam Balado --------- Rp. 15.000" << endl; | |
cout << endl; | |
cout << "Masukkan menu pilihan : "; cin >> pilihan; | |
cout << "Jumlah yang akan dibeli : "; cin >> jumlah; | |
switch(pilihan) { | |
case 1: | |
harga = 12000; | |
break; | |
case 2: | |
harga = 9000; | |
break; | |
case 3: | |
harga = 13000; | |
break; | |
case 4: | |
harga = 15000; | |
break; | |
} | |
harga *= jumlah; | |
} | |
else if(umur < 12 && umur > 0) { | |
cout << "=========== MENU PILIHAN ===========" << endl; | |
cout << "1. Nasi Goreng --------- RP. 11.000" << endl; | |
cout << "2. Ayam Goreng --------- Rp. 9.000" << endl; | |
cout << "3. Ikan Kukus ---------- Rp. 8.000" << endl; | |
cout << endl; | |
cout << "Masukkan menu pilihan : "; cin >> pilihan; | |
cout << "Jumlah yang akan dibeli : "; cin >> jumlah; | |
switch(pilihan) { | |
case 1: | |
harga = 11000; | |
break; | |
case 2: | |
harga = 9000; | |
break; | |
case 3: | |
harga = 8000; | |
break; | |
} | |
harga *= jumlah; | |
} | |
system("cls"); | |
if(user == userAuth && key == keyAuth) { | |
diskon = 0.1 * harga; | |
} | |
else { | |
diskon = 0; | |
} | |
total = harga - diskon; | |
cout << "=== PROGRAM KASIR WARUNG MAKAN ===" << endl << endl; | |
cout << "Harga yang dibeli: Rp. " << harga << endl; | |
if(diskon != 0) { | |
cout << "Diskon Anda : Rp. " << diskon << endl; | |
} else { | |
cout << "Diskon Anda : Rp. " << diskon << endl; | |
} | |
cout << "Total Pembayaran : Rp. " << total << endl; | |
cout << "Uang Anda : Rp. "; cin >> uang; | |
if(uang >= total) | |
cout << "Kembalian Anda : Rp. " << uang - total << endl; | |
else | |
cout << "Uang Anda kurang : Rp. " << total - uang << endl; | |
cout << endl; | |
cout << "========== TERIMA KASIH ==========" << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment