hi danpost
i am practicing this array program where it is say calculate a payroll for a set of employees. I have decided to use a while loop for 3 employees instead of the for loop. in the program you have to prompt for the employees name etc but they have to declare it using arrarys. while doing the calculation part of the program, (i use the if else (selection construct) ) but i am stomp. i got some syntax errors such as,
incomparable types: double and int
bad operand for binary operator * (multiplication symbol)
bad operand for binary operator >
how can i fix that here is the codes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | char gender[] = new char [m]; String employee_firstname[] = new String[ 8 ]; String employee_lastname[] = new String[ 8 ]; double hrswrk[]= new double [ 3 ]; double deductions[]= new double [ 5 ]; double rate_ofpay[]= new double [ 3 ]; while (i < 3 ) { i++; System.out.println( "please enter gender or a to be terminated " ); gender[i] = reader.next().charAt( 0 ); System.out.println( "please enter employee first name" ); employee_firstname[i] = reader.next(); System.out.println( "please enter employee last name" ); employee_lastname[i] = reader.next(); System.out.println( "please enter hours of work" ); hrswrk[i] = reader.nextDouble(); System.out.println( "please enter deductions" ); deductions[i] = reader.nextDouble(); System.out.println( "please enter the rate of pay" ); rate_ofpay[i] = reader.nextDouble(); if (hrswrk == 40 ) { hrs = (hrswrk * rate_ofpay); } else if (hrswrk > 40 ) { double overtime = ( 1.5 * rate_ofpay) } else { net_salary = (gross_salary - deductions) } |