My program is supposed to calculate the income of the user by taking the number of hours worked and their hourly wage. if the person works over 40 hours, thy recieve 1.5 times the amount of their usual hourly wage. for some reason, when 41 hours is entered with $10 per hour, the program outputs $425 when it should output $415. got any ideas why??
Thanks in advanceimport java.util.Scanner; public class WageCalculator { public static void main(String[] args) { Scanner scan = new Scanner(System.in); double hoursworked=0, hoursworked40 = 0, wage, totalpay; int i = 0; System.out.println("Enter number of hours worked: "); hoursworked = scan.nextInt(); System.out.println("Enter hourly wage: "); wage = scan.nextInt(); while (hoursworked >= 0 && hoursworked <= 168 && i < 1){ if(hoursworked > 40){ hoursworked40 = hoursworked - 40; hoursworked40 = hoursworked40 * 1.5; totalpay = (hoursworked + hoursworked40) * wage; System.out.println("Total pay: $" + totalpay); i+=1; }else{ totalpay = hoursworked * wage; System.out.println("Total pay: $" + totalpay); i+=1; } } if(hoursworked < 0 || hoursworked > 168) System.out.println("Your hours need to be between 0 and 168."); } }