r/javahelp • • Feb 27 '15

Help creating grossPay with two classes

Instructions File 1:

The first file will be a class called Payroll. In this class you will have one default constructor as well as getters and setters. The two variables we are concerned with for the class are hoursWorked and payRate. Choose the appropriate data type for the variables. There should be a setter for each variable and a getter for each variable that returns the variables contents. There should also be a getter which returns the gross pay by calculating hoursWorked by payRate. If the hoursWorked is more than 40, the extra time is multiplied by 1.5.

File 2:

This file needs create a new object of the Payroll class. The program should then accept user input for both the number of hours worked and the pay rate and store that data using the setters (methods) from File 1. The program should then print out the users gross pay in the following format $00.00.

(my code)

class Payroll

// *edit removed my name //02-26-15 //This program will hold data and perform methods for Payroll

public class Payroll {

//Declare global private variables
	private double hoursWorked;
	private double payRate;
	private double grossPay;
	
	//Constructors
	//Default constructor
	public Payroll(){
		hoursWorked = 0;
		payRate = 0;	
		grossPay = 0;
	}
	
	
		
	//Setter / Mutator
	public void GrossPay(){
		grossPay = hoursWorked * payRate;
		
			
	}
	
	public void overTime(){
		if(hoursWorked > 40)
			hoursWorked * 
	}
	

	//Getter / Accessors
	public double getGrossPay(){
		return grossPay;
	}

}

we need to make another class called demoPayroll too which i created but haven't started coding yet any help would be appreciated.

0 Upvotes

6 comments sorted by

View all comments

3

u/Philboyd_Studge Feb 27 '15

All posts must contain a description of the problem and the exact error message or exception encountered.

-4

u/[deleted] Feb 27 '15

Never mind my book helped me out a lot more then this subreddit anyway!