PayCheck class... percision error.. help!
this is a program where you enter the wage and hours you work and it spits out the amount of money you should be receiving.. i am getting a possible loss of percision error.
here is my code
public class PayCheck
Scanner in = new Scanner(System.in);
double wage = in.nextDouble();
double hours = in.nextDouble();
public int getPayCheck()
if (hours > 40)
pay = (wage*hours)+((hours%40)*(overtime*wage));
pay = wage*hours;
private double hours;
private double overtime = 1.5;
private double wage;
Re: PayCheck class... percision error.. help!
The modulus operator only operates on integers (I think). Also, you're "double adding" the over-forty hours (one copy at standard wage, and another at the overtime wage).
pay = (wage*40) + ((hours-(hours%40)*40)*(overtime*wage))