Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is my code but my overtime calculation is wrong and I cant figure out how to round to two decimal places import java.util.Scanner; public

This is my code but my overtime calculation is wrong and I cant figure out how to round to two decimal places import java.util.Scanner; public class HourlyWage { public static void main(String[] args) { //Variables double totalWage; double totalOvertimePay; double totalPay; String name; double overtimeHours = 0.0; double hoursWorked = 0.0; double hourlyWage = 0.0; Scanner keyboard = new Scanner(System.in); System.out.println("Please enter your name "); name = keyboard.next(); System.out.println("Please enter your hourly wage "); hourlyWage = keyboard.nextDouble(); System.out.println("How many hours have you worked in the past week"); hoursWorked = keyboard.nextInt(); if(hoursWorked > 40) { overtimeHours = hoursWorked - 40; totalOvertimePay = overtimeHours * ( hourlyWage * 1.5); System.out.print(totalOvertimePay); totalWage = hourlyWage * 40; System.out.print(totalWage); totalPay = totalOvertimePay + totalWage; System.out.printf("10%.2f ", totalPay ); }else if(hoursWorked <= 40) { System.out.println("Your total pay is: " + "$" + hourlyWage * hoursWorked ); } }//close main }//close class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions