Question
Could you look over this program and see why it will not run? Employee.java import java.util.Scanner; public class Employee { public static void main(String[] args)
Could you look over this program and see why it will not run?
Employee.java
import java.util.Scanner;
public class Employee
{
public static void main(String[] args)
{
Scanner input = new Scanner( System.in);
WageCalcu employee = new WageCalcu();
System.out.print( "Enter Employee name: " );
String name = input.nextLine();
employee.setEmployeeName( name );
System.out.print( "Enter how many hours worked: " );
int hours = input.nextInt();
System.out.print( "Enter how many overtime hours worked: " );
int extraHours = hours - 40;
System.out.print(extraHours);
System.out.print( " Enter hourly rate: " );
double rate = input.nextDouble();
employee.calculateRegularPay( hours, rate );
employee.calculateOvertimePay( hours, rate );
employee.calculateGrossPay(hours, rate);
employee.displayEmployee();
System.out.println();
System.out.print("Enter the Diners Cost: ");
double total = input.nextDouble();
employee.tipCalucalator(total);
}
}
WageCalcu.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class WageCalcu
{
private String employeeName;
private int hours;
private double rate, rpay,pay,opay;
public void setEmployeeName ( String name )
{
employeeName = name;
}
public String getEmployeeName()
{
return employeeName;
}
public void displayEmployee()
{
System.out.print( "Employee's name:" + getEmployeeName());
System.out.print( " Regular Salary: " + rpay );
System.out.print( " Overtime Salary: " + opay );
System.out.print( " Gross Salary: " + pay );
}
public double calculateRegularPay(int hours, double rate) {
// TODO Auto-generated method stub
if ( hours > 40 )
{
rpay = ( 40 * rate );
}
else rpay = hours * rate;
return rpay;
}
public double calculateOvertimePay(int hours, double rate) {
if ( hours > 40 )
{
int extraHours = hours - 40;
opay = ( extraHours * rate );
}
else opay = hours * rate;
return opay;
}
public double calculateGrossPay(int hours, double rate) {
// TODO Auto-generated method stub
if ( hours > 40 )
{
int extraHours = hours - 40;
pay = ( 40 * rate ) + (( extraHours * rate ) + (1.5 * rate));
}
else pay = hours * rate;
return pay;
}
public void tipCalucalator(double total)
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int ch;
try
{
double rate1 = 0.2;
double rate2 = 0.15;
double rate3 = 0.1;
System.out.println("1.Total Satisfied");
System.out.println("2.Satisfied");
System.out.println("3.DisSatisfied");
System.out.println("------------------------------------------------------------------------");
System.out.println(" Enter the Diner Satisfaction level ");
ch = Integer.parseInt(br.readLine());
switch(ch)
{
case 1:
System.out.print("Tip " +(total*rate1));
System.out.print("Total Diner cost " +((total*rate1)+ total));
break;
case 2:
System.out.print("Tip " + (total*rate2));
System.out.print("Total Diner cost " +((total*rate2)+ total));
break;
case 3:
System.out.print("Tip " + (total*rate3));
System.out.print("Total Diner cost " +((total*rate3)+ total));
break;
default:
System.out.println(" Oops! wrong choice");
break;
}
}
catch(IOException ca)
{
System.out.println("Exception caught" + ca);
}
}
}
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