Tugas 4 

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> using namespace std; //NAMA : Dhafin Shabir Alfatih //NIM : 3420230036 //PRODI : TEKNIK INFORMATIKA 2023 int main(){ int kodeSusu, jumlahPembelian; char ukuran; string namaProduk; double hargaSatuan, totalHarga; cout << "TUGAS NO 4 | Dhafin Shabir Alfatih | 3420230036" <<endl; cout << "Perusahaan Susu ABC ingin membuat sistem penjualan susu" << endl; cout << "-------------------------------------------------------" << endl; cout << "Masukkan Kode Susu (1-3): "; cin >> kodeSusu; cout << "Masukkan Jumlah Pembelian: "; cin >> jumlahPembelian; cout << "Masukkan Ukuran (B/S/K): "; cin >> ukuran; switch (kodeSusu){ case 1: namaProduk = "Dancow"; switch (ukuran) { case 'B': hargaSatuan = 10.000; break; case 'S': hargaSatuan = 4.250; break; case 'K': hargaSatuan = 2.100; break; default: cout<<"Ukuran Tidak Valid!"<<endl; return 1; } break; case 2: namaProduk = "Indomilk"; switch (ukuran) { case 'B': hargaSatuan = 8.500; break; case 'S': hargaSatuan = 4.000; break; case 'K': hargaSatuan = 2.025; break; default: cout<<"Ukuran Tidak Valid!"<<endl; return 1; } break; case 3: namaProduk = "Sustacal"; switch (ukuran) { case 'B': hargaSatuan = 17.000; break; case 'S': hargaSatuan = 14.500; break; case 'K': hargaSatuan = 8.300; break; default: cout<<"Ukuran Tidak Valid!"<<endl; return 1; } break; default: cout << "Kode Susu Tidak Valid!" << endl; return 1; } totalHarga = hargaSatuan * jumlahPembelian; cout << "\nSusu " << namaProduk << endl; cout << "Harga Susu Rp. " << fixed << hargaSatuan <<endl; cout << "Jumlah Pembelian Rp. " << fixed << totalHarga << endl; return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines