Results 1 to 2 of 2
Thread: Paycheck help
- 11-16-2012, 12:01 AM #1
Member
- Join Date
- Nov 2012
- Posts
- 1
- Rep Power
- 0
Paycheck help
Hey guys......im really stuck on a project its actually wrecking my head i have to...
Write a class PayCheck that uses dialog boxes to compute the total gross pay of an hourly wage worker. The program should use input dialog boxes to get the number of hours worked and the hourly pay rate from the user. The program should use a message dialog to display the total gross pay. The pay calculation should assume the worker earns time and a half for overtime (for hours over 40).
so far i have
//################################################
// Paycheck.java
//
//
//###############################################
import java.util.Scanner;
import javax.swing.*;
import java.awt.event.*;
public class Paycheck{
JFrame frame;
public static void main(String[] args){
Paycheck db = new Paycheck();
}
public Paycheck(){
frame = new JFrame("PayCheck");
frame.setSize(400, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
}
{
{
Scanner in = new Scanner(System.in);
System.out.println("Wage: ");
// this where you type in the hourly wage
double wage = in.nextDouble();
System.out.println("Hours: ");
//this is where the number of hours is enterd
double hours = in.nextDouble();
}
{
double pay;
if (hours > 40)
{
pay = (wage*40) + ((hours-(hours%40)*40)*(overtime*wage));
}
else
{
pay = wage * hours;
}
return int pay;
}
}
}
any help would be much appresiated? :)
- 11-16-2012, 03:09 AM #2
Bookmarks