C++ "Percabangan Bersarang Gaji"
#include <iostream>using namespace std;int main(){int jam, gaji;string nama, gol;cout << "---Pembayaran Gaji---" << endl;cout << endl;cout << "Keterangan Pembayaran Gaji" << endl;cout << "Golongan 1 10000/jam" << endl;cout << "Golongan 2 8000 /jam" << endl;cout << "Golongan 3 6000 /jam" << endl;cout << "Golongan 4 5000 /jam" << endl;cout << "Lembur 7000 /jam" << endl;cout << endl;cout << "Masukkan Nama Anda = " ;cin >> nama;cout << "Masukkan Golongan = " ;cin >> gol;cout << "Masukkan Jumlah Jam Kerja = " ;cin >> jam;if(gol=="1"){
if (jam<=48){
gaji=jam*10000;}
else if (jam>48){
gaji=(48*10000)+((jam-48)*7000);}
}
else if(gol=="2"){
if (jam<=48){
gaji=jam*8000;}
else if (jam>48){
gaji=(48*8000)+((jam-48)*7000);}
}
else if(gol=="3"){
if (jam<=48){
gaji=jam*6000;}
else if (jam>48){
gaji=(48*6000)+((jam-48)*7000);}
}
else if (gol=="4"){
if (jam<=48){
gaji=jam*5000;}
else if (jam>48){
gaji=(48*5000)+((jam-48)*7000);}
}
cout << endl;cout << "Nama : " << nama << endl;cout << "Total Gaji : " << gaji << endl;return 0;}
Hasilnya seperti ini: