Answer to Question #57047 in Java | JSP | JSF for Christian Josef Aquino

Question #57047
Write a JAVA program that will input Employee Name, Rate per hour, No. of hours worked
and will compute the daily wage of an employee. If the number of hours worked exceeds
eight hours add 30% to each excess hours as overtime rate.
Formula: Daily Wage = Rate per hour * No. of hours worked + OT pay
1
Expert's answer
2015-12-18T07:00:01-0500
package com.company;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
double daily_wage = 0;
System.out.println("Enter Employee Name");
String employee_Name = reader.readLine();
System.out.println("Enter Rate per hour");
String rate_str = reader.readLine();
System.out.println("Enter No. of hours worked");
String hours_str = reader.readLine();
double rate;
int hours;
try {
rate = Float.parseFloat(rate_str);
hours = Integer.parseInt(hours_str);
daily_wage = compute_daily_wage(rate,hours);
} catch (NumberFormatException e) {
System.err.println("Wrong format of data!");
}
System.out.println(employee_Name + "'s daily wage " + " - " + daily_wage);
}
public static double compute_daily_wage(double rate, int hours){
double ot_pay = 0;
if(hours > 8)
ot_pay = rate * 30 / 100 * (hours - 8);
return rate * hours + ot_pay;
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS