#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
struct Barang {
string nama;
double harga;
int jumlah;
};
struct Pelanggan {
string NIK;
string nama;
string alamat;
int umur;
long pembelian;
};
int main() {
string password = "password";
string inputPassword;
bool passwordBenar = false;
while (!passwordBenar) {
cout << "Masukkan password: ";
cin >> inputPassword;
if (inputPassword == password) {
passwordBenar = true;
cout << "Password benar. Selamat datang!" << endl;
} else {
cout << "Password salah. Silakan coba lagi." << endl;
}
}
int pilihan;
bool running = true;
while (running) {
cout << "\nMenu Pilihan:" << endl;
cout << "1. Cari Bilangan Prima" << endl;
cout << "2. Bonus Pembelian" << endl;
cout << "3. Diskon Belanja Oni" << endl;
cout << "4. Slip Pembayaran Biaya Kuliah" << endl;
cout << "5. PPN 10%" << endl;
cout << "6. Keluar" << endl;
cout << "Masukkan pilihan (1-6): ";
cin >> pilihan;
if (pilihan == 1) {
int bawah, atas;
cout << "Masukkan batas bawah: ";
cin >> bawah;
cout << "Masukkan batas atas: ";
cin >> atas;
cout << "Bilangan prima antara " << bawah << " dan " << atas << " adalah:\n";
for (int n = bawah; n <= atas; n++) {
bool prime = true;
if (n <= 1) {
prime = false;
}
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
prime = false;
break;
}
}
if (prime) {
cout << n << " ";
}
}
cout << endl;
} else if (pilihan == 2) {
const int bonus_thresholds[] = {500000, 400000, 300000, 200000, 100000};
string bonus[] = {"Tiket ke Swiss", "Jam tangan Rolex", "Tiket ke Bali", "Tiket ke Yogya", "Discount 5%"};
int jumlahPelanggan;
cout << "Masukkan jumlah pelanggan: ";
cin >> jumlahPelanggan;
Pelanggan pelanggan[jumlahPelanggan];
for (int i = 0; i < jumlahPelanggan; i++) {
cout << "\nData Pelanggan " << i + 1 << ":" << endl;
cout << "Masukkan NIK: ";
cin >> pelanggan[i].NIK;
cout << "Masukkan Nama: ";
cin.ignore();
getline(cin, pelanggan[i].nama);
cout << "Masukkan Alamat: ";
getline(cin, pelanggan[i].alamat);
cout << "Masukkan Umur: ";
cin >> pelanggan[i].umur;
cout << "Masukkan Total Pembelian: ";
cin >> pelanggan[i].pembelian;
}
cout << "\nData Pelanggan yang telah dimasukkan:" << endl;
for (int i = 0; i < jumlahPelanggan; i++) {
cout << "\nData Pelanggan " << i + 1 << ":" << endl;
cout << "NIK: " << pelanggan[i].NIK << endl;
cout << "Nama: " << pelanggan[i].nama << endl;
cout << "Alamat: " << pelanggan[i].alamat << endl;
cout << "Umur: " << pelanggan[i].umur << endl;
cout << "Total Pembelian: " << pelanggan[i].pembelian << endl;
if (pelanggan[i].pembelian >= 500000) {
cout << "Bonus: " << bonus[0] << endl;
} else if (pelanggan[i].pembelian >= 400000) {
cout << "Bonus: " << bonus[1] << endl;
} else if (pelanggan[i].pembelian >=300000) {
cout << "Bonus: " << bonus[2] << endl;
} else if (pelanggan[i].pembelian >= 200000) {
cout << "Bonus: " << bonus[3] << endl;
} else if (pelanggan[i].pembelian >=100000) {
cout << "Bonus: " << bonus[4] << endl;
} else if (pelanggan[i].pembelian <100000){
cout << "Maaf, tidak ada bonus untuk pembelian ini." << endl;
}
}
} else if (pilihan == 3) {
double hargaBaju = 100000.0;
double hargaCelana = 100000.0;
double diskonBaju = 25.0;
double diskonCelana = 55.0;
double hargaDiskonBaju = hargaBaju * (1.0 - diskonBaju / 100.0);
double hargaDiskonCelana = hargaCelana * (1.0 - diskonCelana / 100.0);
cout << "Harga baju sebelum diskon: Rp " << hargaBaju << endl;
cout << "Harga baju setelah diskon: Rp " << hargaDiskonBaju << endl;
cout << "Diskon baju: " << diskonBaju << "%" << endl;
cout << "\nHarga celana sebelum diskon: Rp " << hargaCelana << endl;
cout << "Harga celana setelah diskon: Rp " << hargaDiskonCelana << endl;
cout << "Diskon celana: " << diskonCelana << "%" << endl;
double totalBelanja = hargaDiskonBaju + hargaDiskonCelana;
cout << "\nTotal belanja Oni: Rp " << totalBelanja << endl;
} else if (pilihan == 4) {
string namaMahasiswa, npmMahasiswa;
int sksSemester1, sksSemester2, sksSemester3;
cout << "Masukkan nama mahasiswa: ";
cin.ignore();
getline(cin, namaMahasiswa);
cout << "Masukkan NIM mahasiswa: ";
getline(cin, npmMahasiswa);
cout << "Masukkan jumlah SKS semester 1: ";
cin >> sksSemester1;
cout << "Masukkan jumlah SKS semester 2: ";
cin >> sksSemester2;
cout << "Masukkan jumlah SKS semester 3: ";
cin >> sksSemester3;
int totalSemester1 = 3000000 + 5000000 + (sksSemester1 * 250000);
int totalSemester2 = 3000000 + (sksSemester2 * 250000);
int totalSemester3 = 3000000 + (sksSemester3 * 250000);
int totalTigaSemester = totalSemester1 + totalSemester2 + totalSemester3;
cout << "\n*Slip Pembayaran Biaya Kuliah*" << endl;
cout << "Nama Mahasiswa: " << namaMahasiswa << endl;
cout << "Nomor Induk Mahasiswa (NIM): " << npmMahasiswa << endl;
cout << "\n*Semester 1:*" << endl;
cout << "- SPP: Rp 3.000.000" << endl;
cout << "- Biaya Pembangunan: Rp 5.000.000" << endl;
cout << "- Biaya SKS: Rp " << sksSemester1 * 250000 << endl;
cout << "Total Biaya Semester 1: Rp " << totalSemester1 << endl;
cout << "\n*Semester 2:*" << endl;
cout << "- SPP: Rp 3.000.000" << endl;
cout << "- Biaya SKS: Rp " << sksSemester2 * 250000 << endl;
cout << "Total Biaya Semester 2: Rp " << totalSemester2 << endl;
cout << "\n*Semester 3:*" << endl;
cout << "- SPP: Rp 3.000.000" << endl;
cout << "- Biaya SKS: Rp " << sksSemester3 * 250000 << endl;
cout << "Total Biaya Semester 3: Rp " << totalSemester3 << endl;
cout << "\n*Total Biaya Kuliah 3 Semester:* Rp " << totalTigaSemester << endl;
} else if (pilihan == 5) {
const double PPN = 0.10;
int jumlahBarang;
cout << "Masukkan jumlah jenis barang: ";
cin >> jumlahBarang;
Barang daftarBarang[jumlahBarang];
for (int i = 0; i < jumlahBarang; ++i) {
cout << "\nData Barang " << i + 1 << ":" << endl;
cout << "Masukkan nama barang: ";
cin.ignore();
getline(cin, daftarBarang[i].nama);
cout << "Masukkan harga barang: ";
cin >> daftarBarang[i].harga;
cout << "Masukkan jumlah barang: ";
cin >> daftarBarang[i].jumlah;
}
double totalHarga = 0.0;
double totalPPN = 0.0;
cout << "\nNota Pembelian\n";
cout << "------------------------\n";
for (int i = 0; i < jumlahBarang; ++i) {
double totalHarga = daftarBarang[i].harga * daftarBarang[i].jumlah;
double ppnBarang = totalHarga * PPN;
totalHarga += totalHarga;
totalPPN += ppnBarang;
cout << "Barang " << i + 1 << ": " << daftarBarang[i].nama << endl;
cout << "Harga per barang: Rp " << daftarBarang[i].harga << endl;
cout << "Jumlah barang : " << daftarBarang[i].jumlah << endl;
cout << "total harga : Rp " << fixed << setprecision(2) << totalHarga << endl;
cout << "PPN 10% : Rp " << ppnBarang << endl;
cout << "------------------------\n";
}
double totalPembayaran = totalHarga + totalPPN;
cout << "Total Harga : Rp " << totalHarga << endl;
cout << "Total PPN : Rp " << totalPPN << endl;
cout << "Total Pembayaran: Rp " << totalPembayaran << endl;
cout << "------------------------\n";
} else if (pilihan == 6) {
running = false;
} else {
cout << "Pilihan tidak tersedia. Silakan pilih lagi.\n";
}
}
cout << "Terima kasih telah menggunakan program ini.\n";
return 0;
}
No comments:
Post a Comment