Question
An employees total weekly pay equals the hourly wage multiplied by the total number of regular hours plus any overtime pay. Overtime pay equals the
An employees total weekly pay equals the hourly wage multiplied by the total number of regular hours plus any overtime pay. Overtime pay equals the total overtime hours multiplied by 1.5 times the hourly wage. Write a program that takes as inputs the hourly wage, total regular hours, and total overtime hours and displays an employees total weekly pay.
The code in JAVA I have for this is:
import java.util.Scanner;
public class Main {
public static void main (String[] args) {
Scanner scanner= new Scanner(System.in);
System.out.println ("Enter hourly wage: ");
int hourlyWage = scanner.nextInt();
System.out.println ("Enter regular hours: ");
int regularHours = scanner.nextInt();
System.out.println ("Enter total overtime hours: ");
int overTimehours = scanner.nextInt();
totalOvertimehours = (overTimehours * 1.5 * hourlyWage);
totalWeeklypay = (hourlyWage * regularHours) + (totalOvertimehours);
System.out.println(totalWeeklypay);
}
}
I keep getting the following error message in repl.it
Main.java:11: error: incompatible types: possible lossy conversion from double to int totalOvertimehours = (totalOvertimehours * 1.5 * hourlyWage); ^ Main.java:12: error: cannot find symbol totalWeeklypay = (hourlyWage * regularHours) + (totalOvertimehours); ^ symbol: variable totalWeeklypay location: class Main Main.java:13: error: cannot find symbol System.out.println(totalWeeklypay); ^ symbol: variable totalWeeklypay location: class Main 3 errors
Can someone help me correct my mistakes? Thanks!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started