#include <iostream>
#include <iomanip>
using namespace std;
int main() {
string namaKaryawan[10], jabatan[10], alamat[10], telepon[10];
int gajiPokok[10], bonusTeknisi[10], bonusSales[10], hutangLalu[10], hutangBulanIni[10], potonganGaji[10], sisaHutang[10], totalGaji[10];
int jumlahSlip;
cout << "Masukkan jumlah slip gaji: ";
cin >> jumlahSlip;
cin.ignore(); // Mengabaikan karakter newline (\n)
// Memasukkan informasi karyawan
for (int i = 0; i < jumlahSlip; i++) {
cout << "\nSlip Gaji " << i+1 << endl;
cout << "Masukkan Nama karyawan: ";
getline(cin, namaKaryawan[i]);
cout << "Masukkan Jabatan : ";
getline(cin, jabatan[i]);
cout << "Masukkan Alamat : ";
getline(cin, alamat[i]);
cout << "Masukkan Telepon : ";
getline(cin, telepon[i]);
cout << "\nMasukkan Gaji pokok : Rp.";
cin >> gajiPokok[i];
cout << "Masukkan Bonus teknisi: Rp.";
cin >> bonusTeknisi[i];
cout << "Masukkan Bonus sales : Rp.";
cin >> bonusSales[i];
cout << "\nMasukkan Hutang bulan lalu : Rp.";
cin >> hutangLalu[i];
cout << "Masukkan Hutang bulan ini : Rp.";
cin >> hutangBulanIni[i];
cout << "\nMasukkan Potongan gaji : Rp.";
cin >> potonganGaji[i];
cin.ignore(); // Mengabaikan karakter newline (\n)
// Menghitung total gaji
sisaHutang[i] = hutangLalu[i] + hutangBulanIni[i] - potonganGaji[i];
totalGaji[i] = gajiPokok[i] + bonusTeknisi[i] + bonusSales[i] + sisaHutang[i];
system("cls");
}
// Menampilkan slip gaji dalam format yang diinginkan
for (int i = 0; i < jumlahSlip; i++) {
cout << "============================================================\n";
cout << " SLIP GAJI " << i+1 << endl;
cout << "============================================================\n";
cout << "TOKO MAJU\n";
cout << "Jl. Bangka 123 Jember 12345\n";
cout << "Telp. 0331-123-456\n";
cout << "------------------------------------------------------------\n";
cout << "Nama : " << namaKaryawan[i] << setw(35 - namaKaryawan[i].length()) << "Alamat :\t" << alamat[i] << endl;
cout << "Jabatan : " << jabatan[i] << setw(36 - jabatan[i].length()) << "Telepon: \t" << telepon[i] << endl;
cout << "------------------------------------------------------------\n";
cout << left << setw(4) << " NO" << setw(45) << "KETERANGAN" << setw(32) << "JUMLAH" << endl;
cout << "------------------------------------------------------------\n";
cout << left << setw(4) << " 1" << setw(42) << "Gaji Pokok" << "Rp." << right << setw(6) << fixed << setprecision(0) << gajiPokok[i] << endl;
cout << left << setw(4) << " 2" << setw(42) << "Bonus Teknisi" << "Rp." << right << setw(6) << fixed << setprecision(0) << bonusTeknisi[i] << endl;
cout << left << setw(4) << " 3" << setw(42) << "Bonus Sales" << "Rp." << right << setw(6) << fixed << setprecision(0) << bonusSales[i] << endl;
cout << left << setw(4) << " 4" << setw(42) << "Lain-lain" << "Rp." << right << setw(6) << fixed << setprecision(0) << sisaHutang[i] << endl;
cout << left << setw(4) << " 5" << setw(42) << "Hutang bulan lalu" << "Rp." << right << setw(6) << fixed << setprecision(0) << hutangLalu[i] << endl;
cout << left << setw(4) << " 6" << setw(42) << "Hutang bulan ini" << "Rp." << right << setw(6) << fixed << setprecision(0) << hutangBulanIni[i] << endl;
cout << left << setw(4) << " 7" << setw(42) << "Potongan gaji" << "Rp." << right << setw(6) << fixed << setprecision(0) << potonganGaji[i] << endl;
cout << left << setw(4) << " 8" << setw(42) << "Sisa hutang" << "Rp." << right << setw(6) << fixed << setprecision(0) << sisaHutang[i] << endl;
cout << "------------------------------------------------------------\n";
cout << left << setw(46) << "Total Diterima :" << "Rp." << right << setw(6) << fixed << setprecision(0) << totalGaji[i] << endl;
cout << endl;
}
cout <<endl;
return 0;
}
No comments:
Post a Comment