- Beranda
- Komunitas
- Tech
- Programmer Forum
[ASK] C++ Dasar
TS
epba
[ASK] C++ Dasar
Permisi para master sekalian, numpang tanya.
#include<iostream>
using namespace std;
int main()
{
string nama;/**/char gol;
int gaji_pokok;
long int gaji_lembur=50000,lama_lembur;
AWAL :
cout<<" ==========================================================\n";
cout<<" :: DAFRAT PERHITUNGAN GAJI PEGAWAI ::\n";
cout<<" ==========================================================\n\n";
cout<<"Nama Pegawai : ";getline(cin, nama);
cout<<"Golongan<1,2,3> : ";cin>>gol;
cout<<"Lama Lembur : ";cin>>lama_lembur;
cout<<"\n";
//Penentuan Gaji_Pokok
if (gol == '1')/**/{gaji_pokok=800000;}
else if (gol == '2')/**/{gaji_pokok=1200000;}
else if (gol == '3')/**/{gaji_pokok=2500000;}
//-Penentuan Gaji_Pokok
system("cls");
cout<<" ==========================================================\n";
cout<<" :: DAFRAT PERHITUNGAN GAJI PEGAWAI ::\n";
cout<<" ==========================================================\n\n";
cout<<"Nama Pegawai : "<<nama<<"\n";
cout<<"Golongan<1,2,3> : "<<gol<<"\n";
cout<<"\n";
//Rumus Perhitungan
int total_gaji_lembur=gaji_lembur*lama_lembur;
long int gaji_kotor=total_gaji_lembur+gaji_pokok;
long int pajak=25*(gaji_kotor/1000);
long int total_gaji_kotor=gaji_pokok+total_gaji_lembur;
long int asuransi=5*(total_gaji_kotor/100);
long int gaji_bersih=total_gaji_kotor-(asuransi+pajak);
//-Rumus Perhitungan
cout<<"Gaji Pokok : Rp."<<gaji_pokok<<"\n";
cout<<"Lama Lembur : "<<lama_lembur<<" Jam\n";
cout<<"Total Gaji Lembur : Rp."<<total_gaji_lembur<<"\n";
cout<<"Gaji Kotor : Rp."<<gaji_kotor<<"\n";
cout<<"\n";
cout<<"POTONGAN \n";
cout<<"Pajak <2,5%> : Rp."<<pajak<<"\n";
cout<<"Asuransi <5%> : Rp."<<asuransi<<"\n";
cout<<"Gaji Bersih : Rp."<<gaji_bersih<<"\n\n";
system("PAUSE");
}
[/CODE]
Diatas kan ada input golongan 1/2/3, Saya pengin kalo misalkan ada yg nginput selain 1/2/3 programnya jalan dari awal lagi .... gimana ya caranya ?
saya udah coba gini :
- nambahin label AWAL di source code paling atas
-nambahin perintah goto supaya bisa ke label awal...
eh jadinya malah ga karuan ...
#include<iostream>
using namespace std;
int main()
{
string nama;/**/char gol;
int gaji_pokok;
long int gaji_lembur=50000,lama_lembur;
AWAL :
cout<<" ==========================================================\n";
cout<<" :: DAFRAT PERHITUNGAN GAJI PEGAWAI ::\n";
cout<<" ==========================================================\n\n";
cout<<"Nama Pegawai : ";getline(cin, nama);
cout<<"Golongan<1,2,3> : ";cin>>gol;
cout<<"Lama Lembur : ";cin>>lama_lembur;
cout<<"\n";
//Penentuan Gaji_Pokok
if (gol == '1')/**/{gaji_pokok=800000;}
else if (gol == '2')/**/{gaji_pokok=1200000;}
else if (gol == '3')/**/{gaji_pokok=2500000;}
//-Penentuan Gaji_Pokok
system("cls");
cout<<" ==========================================================\n";
cout<<" :: DAFRAT PERHITUNGAN GAJI PEGAWAI ::\n";
cout<<" ==========================================================\n\n";
cout<<"Nama Pegawai : "<<nama<<"\n";
cout<<"Golongan<1,2,3> : "<<gol<<"\n";
cout<<"\n";
//Rumus Perhitungan
int total_gaji_lembur=gaji_lembur*lama_lembur;
long int gaji_kotor=total_gaji_lembur+gaji_pokok;
long int pajak=25*(gaji_kotor/1000);
long int total_gaji_kotor=gaji_pokok+total_gaji_lembur;
long int asuransi=5*(total_gaji_kotor/100);
long int gaji_bersih=total_gaji_kotor-(asuransi+pajak);
//-Rumus Perhitungan
cout<<"Gaji Pokok : Rp."<<gaji_pokok<<"\n";
cout<<"Lama Lembur : "<<lama_lembur<<" Jam\n";
cout<<"Total Gaji Lembur : Rp."<<total_gaji_lembur<<"\n";
cout<<"Gaji Kotor : Rp."<<gaji_kotor<<"\n";
cout<<"\n";
cout<<"POTONGAN \n";
cout<<"Pajak <2,5%> : Rp."<<pajak<<"\n";
cout<<"Asuransi <5%> : Rp."<<asuransi<<"\n";
cout<<"Gaji Bersih : Rp."<<gaji_bersih<<"\n\n";
system("PAUSE");
}
[/CODE]
Diatas kan ada input golongan 1/2/3, Saya pengin kalo misalkan ada yg nginput selain 1/2/3 programnya jalan dari awal lagi .... gimana ya caranya ?
saya udah coba gini :
- nambahin label AWAL di source code paling atas
-nambahin perintah goto supaya bisa ke label awal...
eh jadinya malah ga karuan ...
Quote:
bisabantu kasih solusinya ga ?0
595
3
Komentar yang asik ya
Urutan
Terbaru
Terlama
Komentar yang asik ya
Komunitas Pilihan