Write an application that calculates and and displays the weekly salary for an e
ID: 644569 • Letter: W
Question
Write an application that calculates and and displays the weekly salary for an employee.
The main() method prompts the user for an hourly pay rate, regular hours, and overtime
hours. Create a seperate method to calculate overtime pay, which is regular hours times
the pay rate plus overtime hours times 1.5 times the pay rate; return he result to the
main() method to be displayed. Save the program as Salary.java.
*Note: I am using Eclipse Luna and and am on chapter 4. Please make sure the code meets both of those requirements.
Most of the codes I am getting won't run in Eclipse. Thank uou.
Explanation / Answer
import java.util.Scanner;
public class HelloWorld{
public static void main(String []args){
Scanner sc = new Scanner(System.in);
System.out.println("Enter hourly rate");
double hourlyRate = sc.nextInt();
System.out.println("Enter regular hours");
double regularHours = sc.nextInt();
System.out.println("Enter overtimr hours");
double overtimeHours = sc.nextInt();
double pay=0;
pay=pay+(regularHours*hourlyRate);
double salary = calculateOverTimePay(overtimeHours,pay,hourlyRate);
System.out.println("Total salary to be paid is:-----> "+salary);
}
public static double calculateOverTimePay(double overtime, double salaryPay,double rate){
salaryPay=salaryPay+(overtime*rate*1.5);
return salaryPay;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.