Kenapa illegal use of pointer ?

terus aja "illegal use of pointer" dan "possible use of 'gk' before definition" ada bisa bantu ? Ini codenya, maaf pemula dan kasi tau kalo programnya ada yang salah ya wkwk

#include <iostream>
#include <conio>
#include <stdio>

int main()
{

int jk, gk, ul, l;
char nk[2];
char g[4];

cout<<"--------------------------"<<endl;
cout<<"ALAT PENGHITUNG GAJI SUPER"<<endl;
cout<<"--------------------------"<<endl;
cout<<endl;
cout<<"Nama karyawan : ";
cin>>nk;
cout<<"Golongan a/b/c/d : ";
cin>>g;
cout<<"Total jam kerja : ";
cin>>jk;

'g'<-'a', 'b', 'c', 'd';
'a'<-4000;
'b'<-5000;
'c'<-6000;
'd'<-7500;

if (jk<=48)
{
	gk=jk*g;
}
else if (jk>48)
{
	l=jk-48;
}
if (l>3)
{
	ul=l*3000+9000;
}
else if (l<=3)
{
	l=l*6000;
}

gk=jk*g+ul;
cout<<"---------"<<endl;
cout<<"Result..."<<endl;
cout<<"---------"<<endl;

cout<<"Nama Karyawan : "<<nk<<"\n"<<endl;
cout<<"Golongan : "<<g<<"\n"<<endl;
cout<<"Total jam kerja : "<<jk<<"\n"<<endl;
cout<<"Upah lembur : "<<ul<<"\n"<<endl;
cout<<"Total gaji karyawan : "<<gk<<"\n"<<endl;

getch();
}

avatar okkysatria
@okkysatria

1 Kontribusi 0 Poin

Diperbarui 4 tahun yang lalu

1 Jawaban:

coba gini aj.. #include<iostream> #include<string> using namespace std; int main(){ string nk; char g; int jk=0,ul=0; cout<<"Masukan Nama Karyawan : "; cin>>nk; cout<<"Masukan Golongan Karyawan(a,b,c,d) : "; cin>>g; cout<<"Masukan Jumlah Jam Kerja : "; cin>>jk: if(jk>48){ ul=jk-48; jk=48; } if(ul<=3){ ul*=6000; }else if(ul>3){ ul=(ul3000)+9000; if(g=='a'){ gk=jk4000; }else if(g=='b'){ gk=jk5000; }else if(g=='c'){ gk=jk6000; }else if(g=='d'){ gk=jk*7000; } cout<<"Nama Karyawan : "+nk<<endl <<"Golongan : "+g<<endl <<"Total Jam Kerja : "<<jk<<endl <<"Upah Lembur : "<<ul<<endl <<"Total Gaji Karyawan : "<<gk+ul;

avatar dwiramadhan
@dwiramadhan

8 Kontribusi 4 Poin

Dipost 4 tahun yang lalu

Login untuk ikut Jawaban