Program Hitung Gaji Karyawan
Team 1 OOP THCA BINUSunknown
c_cpp
a year ago
2.2 kB
13
Indexable
#include <iostream> using namespace std; // function int nilaiGaji(int golongan) { int gaji; if (golongan == 1) { gaji = 5000000; } else if (golongan == 2) { gaji = 4000000; } else if (golongan == 3) { gaji = 3000000; } else if (golongan == 4) { gaji = 2000000; } return gaji; } int nilaiPajak(int golongan, int totalGaji) { int pajak; if (golongan == 1) { pajak = 0.05 * totalGaji; } else if (golongan == 2) { pajak = 0.04 * totalGaji; } else if (golongan == 3) { pajak = 0.03 * totalGaji; } else if (golongan == 4) { pajak = 0.02 * totalGaji; } return pajak; } int nilaiLemburan(int golongan, int jamLembur) { int lemburan; if (golongan == 3) { if (jamLembur > 0 && jamLembur <= 3) { lemburan = 100000; } else if (jamLembur > 3) { lemburan = 100000 + 50000; } else lemburan = 0; } else if (golongan == 4) { if (jamLembur > 0 && jamLembur <= 3) { lemburan = 150000; } else if (jamLembur > 3) { lemburan = 150000 + 50000; } else lemburan = 0; } else lemburan = 0; return lemburan; } int nilaiGajiGross(int totalGaji, int totalLemburan, int totalPajak) { return totalGaji + totalLemburan - totalPajak; } int main() { int golongan; int jamLembur; cout<<"---------------------------------------------\n"; cout<<"| PROGRAM HITUNG GAJI KARYAWAN |\n"; cout<<"---------------------------------------------\n\n"; // input user cout << "Masukkan Golongan: "; cin >> golongan; cout << "Masukkan Jumlah Jam Lembur: "; cin >> jamLembur; cout << "\n\n"; // output int totalGaji = nilaiGaji(golongan); int totalPajak = nilaiPajak(golongan, totalGaji); int totalLemburan = nilaiLemburan(golongan, jamLembur); int totalGajiGross = nilaiGajiGross(totalGaji, totalLemburan, totalPajak); cout << "Gaji Pokok : " << totalGaji << endl; cout << "Total Pajak : " << totalPajak << endl; cout << "Total Lemburan : " << totalLemburan << endl; cout << "Gaji Gross : " << totalGajiGross << endl; return 0; }
Editor is loading...
Leave a Comment