Employees get paid time and a half for hours worked in excess of 40 hours. Write
ID: 3744697 • Letter: E
Question
Employees get paid time and a half for hours worked in excess of 40 hours. Write a Java program that calculates the employee's total salary:
1. Prompt the user to enter the salary of the employee.
2. Prompt the user to enter the number of hours the employee worked.
3. Calculate the total salary as follows: a. Employees receive regular salary for the first 40 hours worked. b. Employees receive salary * 1.5 for every hour worked over 40 hours.
4. Display the total salary of the employee.
Name your file as follows: lastName_firstInitial_Project#.java
Explanation / Answer
import java.util.Scanner; public class Cristiano_Ronaldo_Project { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter your salary: "); double salary = in.nextDouble(); System.out.print("Enter the number of hours worked: "); int hours = in.nextInt(); double totalSalary = 0; if(hoursRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.