Monday, 16 December 2024

Program Pengeluaran

 #include <iostream>

#include <iomanip>

using namespace std;

int main() {

    const int kategori = 3;

    const int item[3] = {6, 3, 2};

    string keterangan[kategori][6] = {

        {"Biaya Makan", "Sewa Tempat Tinggal", "Biaya Listrik & Air", "Biaya Pulsa & Internet", "Biaya Belanja Lain-lain", "Transportasi"},

        {"Biaya Hiburan / Rekreasi", "Hobi", "Pengeluaran Sosial"},

        {"Tabungan & Dana Darurat", "Cicilan Pinjaman"}

    };


    int frekuensi[kategori][6] = {};

    int satuan[kategori][6] = {};

    int jumlah[kategori][6] = {};

    int total[kategori] = {};

    int total_pengeluaran = 0;

    

    cout << "Masukkan data pengeluaran berdasarkan kategori:\n";

    for (int i = 0; i < kategori; i++) {

        cout << "\nKategori: ";

        if (i == 0) cout << "KEBUTUHAN (60%)";

        else if (i == 1) cout << "KEINGINAN (20%)";

        else cout << "TABUNGAN & INVESTASI (20%)";

        cout << endl;


        for (int j = 0; j < item[i]; j++) {

            cout << " - " << keterangan[i][j] << endl;

            cout << "   Frekuensi: ";

            cin >> frekuensi[i][j];

            cout << "   Biaya Satuan (Rp): ";

            cin >> satuan[i][j];

        }

    }


    for (int i = 0; i < kategori; i++) {

        for (int j = 0; j < item[i]; j++) {

            jumlah[i][j] = frekuensi[i][j] * satuan[i][j];

            total[i] += jumlah[i][j];

        }

        total_pengeluaran += total[i];

    }


    cout << "\n-------------------------------------------------------------" << endl;

    cout << setw(20) << left << "KATEGORI" << setw(30) << "KETERANGAN" << setw(10) << "JUMLAH" << endl;

    cout << "-------------------------------------------------------------" << endl;


    string nama_kategori[] = {"KEBUTUHAN (60%)", "KEINGINAN (20%)", "TABUNGAN & INVESTASI (20%)"};

    for (int i = 0; i < kategori; i++) {

        cout << nama_kategori[i] << endl;

        for (int j = 0; j < item[i]; j++) {

            cout << setw(20) << "" << setw(30) << keterangan[i][j] << "Rp. " << jumlah[i][j] << endl;

        }

        cout << setw(20) << "" << setw(30) << "Subtotal" << "Rp. " << total[i] << endl;

        cout << "-------------------------------------------------------------" << endl;

    }


    cout << "TOTAL PENGELUARAN DALAM 1 BULAN: Rp. " << total_pengeluaran << endl;


    cout << "Klasifikasi Pengeluaran: ";

    if (total_pengeluaran <= 4000000) {

        cout << "Hemat" << endl;

    } else if (total_pengeluaran <= 5000000) {

        cout << "Cukup" << endl;

    } else {

        cout << "Boros" << endl;

    }


    return 0;

}

No comments:

Post a Comment