tbarnes2788
Programmer
I need help!! I am writing a problem the in interactive and will calculate a companys payroll. My problem is I can not get the program to execute all after first method. That is it will allow me to enter the requested information but will stop after info entered and displayed. Also having a problem with my "if" statement. Here's the code, please tell me what I'm doing wrong? Thanks
import javax.swing.*;
public class Pay
{
public static void main(String[] args) throws Exception{
int hoursWorked = 0;
System.out.println("Enter hours worked");
System.out.println(" 40 hours");
System.out.println(" 45 hours");
System.out.println(" 50 hours");
String hrsWork = JOptionPane.showInputDialog("Enter Hours Worked");
hoursWorked = Integer.parseInt(hrsWork);
System.out.println(hoursWorked);
double payRate=0;
System.out.println("Enter Pay Rate");
System.out.println("7.00");
System.out.println("10.00");
System.out.println("12.00");
String rate = JOptionPane.showInputDialog("Enter Pay Rate");
payRate= Integer.parseInt(rate);
System.out.println(payRate); }
public double calculatePay(double payRate, double regularPay){
double pRate = payRate;
regularPay = pRate * 40;
System.out.println( "Regular Pay is " + regularPay);
return regularPay;}
public double overTimePay(double hoursWorked, double payRate){
double overTimePay;
double hrsWk = hoursWorked;
overTimePay = (hoursWorked - 40) * 2 * payRate;
System.out.println("OverTimePay is " + (hoursWorked - 40) * 2 * payRate);
return overTimePay;}
if(hoursWorked > 40){
regularPay = 40 * payRate;
overTimePay = (hoursWorked - 40) * 2 * payRate;}
else{
regularPay= hoursWorked * payRate;
overTimePay = 0.0;}
System.out.println("Regular Pay for 40 hours is " + regularPay);
System.out.println("Overtime Pay is " + overTimePay);
}
import javax.swing.*;
public class Pay
{
public static void main(String[] args) throws Exception{
int hoursWorked = 0;
System.out.println("Enter hours worked");
System.out.println(" 40 hours");
System.out.println(" 45 hours");
System.out.println(" 50 hours");
String hrsWork = JOptionPane.showInputDialog("Enter Hours Worked");
hoursWorked = Integer.parseInt(hrsWork);
System.out.println(hoursWorked);
double payRate=0;
System.out.println("Enter Pay Rate");
System.out.println("7.00");
System.out.println("10.00");
System.out.println("12.00");
String rate = JOptionPane.showInputDialog("Enter Pay Rate");
payRate= Integer.parseInt(rate);
System.out.println(payRate); }
public double calculatePay(double payRate, double regularPay){
double pRate = payRate;
regularPay = pRate * 40;
System.out.println( "Regular Pay is " + regularPay);
return regularPay;}
public double overTimePay(double hoursWorked, double payRate){
double overTimePay;
double hrsWk = hoursWorked;
overTimePay = (hoursWorked - 40) * 2 * payRate;
System.out.println("OverTimePay is " + (hoursWorked - 40) * 2 * payRate);
return overTimePay;}
if(hoursWorked > 40){
regularPay = 40 * payRate;
overTimePay = (hoursWorked - 40) * 2 * payRate;}
else{
regularPay= hoursWorked * payRate;
overTimePay = 0.0;}
System.out.println("Regular Pay for 40 hours is " + regularPay);
System.out.println("Overtime Pay is " + overTimePay);
}