tugas pertemuan 2 ALGORITMA DAN STRUKTUR DATA
123456789101112131415161718192021222324252627282930313233343536
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main() {
// tugas 2.2
// nama :maimon taha
// nim : 3420250020
// prodi: teknik informatika
// Deklarasi variabel
string namaProduk = "Tas Olahraga";
float hargaSatuan = 120000.0f;
float jumlahBeli = 2.0f;
float persenDiskon = 10.0f;
// Perhitungan
float subtotal = hargaSatuan * jumlahBeli;
float diskon = subtotal * (persenDiskon / 100.0f);
float total = subtotal - diskon;
// Format output 2 angka di belakang koma
cout << fixed << setprecision(2);
// Tampilan output
cout << "-------------------------------------------" << endl;
cout << "Program Penjualan " << namaProduk << endl;
cout << "-------------------------------------------" << endl;
cout << left << setw(18) << "Harga Satuan" << ": Rp " << hargaSatuan << endl;
cout << left << setw(18) << "Jumlah Beli" << ": " << (int)jumlahBeli << endl;
cout << "-------------------------------------------" << endl;
cout << left << setw(18) << "Subtotal" << ": Rp " << subtotal << endl;
cout << left << setw(18) << "Diskon 10 Persen" << ": Rp " << diskon << endl;
cout << left << setw(18) << "Total" << ": Rp " << total << endl;
cout << "-------------------------------------------" << endl;
return 0;
}
Cpp
INFO