Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-29-2011, 09:07 AM   PM User | #1
stevanio
New to the CF scene

 
Join Date: May 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
stevanio is an unknown quantity at this point
Exclamation Create a class that calculates and displays pay of emplyees based on the data entered

Hi guys, I'm having trouble with this JAVA assingment we got at school and a friend recommended this forum for me... It's pretty basic, but I'm a bit , becouse we did this stuff like 5 months ago, and I have forgotten most of it...at first I tought it was a GUI assignment, so I did everything in GUI, but then the teacher said we're not supposed to do it that way.

Anyway...I've asked her for help, but she said, just do this and that and you add this and that's it ..I have no idea what she was talking about.

We're using Jens Editor and we're supposed to use ReadKb to get input from the user and than display information.

So this is the assingment:
It's got two parts.

PART 1:

Create a class using Java that calculates and displays the gross and net pay of an employee based on the data entered by the user.

When designing your class ensure you address the following points:

* Name the class EmployeePayroll

* The class is to contain fields to record the employee’s first name, last name, ID, hours worked, hourly pay rate, gross pay, and net pay.

* The class is to include a default constructor used to initialise the fields for first name, last name, and ID to empty strings; hours worked and pay rate to zero.

* The class is to include a second constructor that accepts values for first name, last name, ID, hours worked, and pay rate and initialises their corresponding field values accordingly.

* Each field should have its own getter method that returns its value.

* Setter methods are required for the first name, last name, ID, hours worked, and pay rate fields.

* Separate methods are necessary to calculate gross pay and net pay using the supplied formulas. Neither of these methods returns a value.

* A method is required to display an employee’s payslip, containing all their details including gross and net pay. This method should call on the appropriate getter methods to access the employee’s details.

* Tax rate is a fixed value of 42% (0.42).

* Use of appropriate code comments.


I have absolutly no idea where to start, I can't remember how we used to do this (we did simple version of this before. but I can't find the project files anywhere on my pc, I think they got wiped from the school computer somehow. )

They gave us these formulas to work with:

For employees who have worked up to 38 hours:
gross pay = hours worked * pay rate

For employees who have worked up to 42 hours:
gross pay = 38 * pay rate + (hours worked – 38) * 1.5 * pay rate

For employees who have worked up to 60 hours:
gross pay = 38 * pay rate + 4 * 1.5 * pay rate + (hours worked – 42) * 2 * pay rate

net pay = gross pay – (gross pay * tax rate)


PART 2:

Create a class to test the functionality of your EmployeePayroll class.

When designing this class ensure you address the following points:

* Name the class TestEmployeePayroll

* Instantiate one EmployeePayroll object that initially sets the first name, last name, and ID fields to your name and student number, the pay rate field to 20.00 and the hours worked field to 38.0.

* Instantiate a second EmployeePayroll object using the default constructor.

* Instantiate an object of the ReadKb class so that your test class can receive user input from the keyboard.

* User input is required for first name, last name, ID, hours worked and pay category (see following table)

* Validation is required for user input of hours worked (must be between 0 and 60 inclusively) and pay category (must be between 1 and 4 inclusively). Assume the user will enter only numeric input for these values.

* The values entered by the user are to be assigned to the fields of the second EmployeePayroll object using the appropriate setter methods.

* Calculate gross and net pay for each EmployeePayroll object.

* Display a pay slip for each employee.

* Use of appropriate code comments.

Hint:
Use a switch statement to allocate employee pay rate based on the entered pay category value.

If anyone can help, I would be immensely grateful.
stevanio is offline   Reply With Quote
Old 05-29-2011, 10:58 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,396
Thanks: 18
Thanked 352 Times in 351 Posts
sunfighter is on a distinguished road
Where is your code?
sunfighter is offline   Reply With Quote
Old 05-30-2011, 04:44 AM   PM User | #3
ShaneC
Codeasaurus Rex


 
Join Date: Jun 2008
Location: Redmond, WA
Posts: 659
Thanks: 31
Thanked 100 Times in 94 Posts
ShaneC is on a distinguished road
As sunfighter has suggested, CF has a very specific homework policy:

Quote:
Do not post your entire homework assignment and request that other members do it for you. This is considered cheating, and your thread may even be used by your school to prove your guilt. Now, you may ask for advice or help on a specific aspect of your assignment that you're having trouble with. Use common sense as far as what's acceptable in terms of soliciting help with homework assignments.
Now, if you'd like help with a specific problem then that is perfectly alright. Just post your thought process so far, with any relevant code, and CF members will be happy to assist you.
__________________
Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com
ShaneC is offline   Reply With Quote
Old 05-31-2011, 01:15 AM   PM User | #4
stevanio
New to the CF scene

 
Join Date: May 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
stevanio is an unknown quantity at this point
Ok, fair enough..

So, ive started with the basics..
Code:
/* 
   FileName: EmployeePayroll.java
*/

public class EmployeePayroll{
                  
    private String Name;
    private String LastName;
    private int ID;
    private int hoursWorked;
    private int payRate;
    private int grossPay;
    private int netPay;
    
     public EmployeePayroll(){
So know I need to add constructors..how would I go about doing that?
(I hope this gives you an idea how badly they are teaching as here..whenever we need help, teacher just says google it )

Also, should use something else instead of 'int' for payRate,grossPay and netPay?

Should I import all the stuff I need now or do it when it's needed as I go along.
I thinkg I'll have to import these:
Code:
import java.util.Scanner;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
I just want to learn this thing properly..so when/if you post any code, can you pls explain what its doing or how the program is gonna use it later.
stevanio is offline   Reply With Quote
Reply

Bookmarks

Tags
calculates, class, create, employee, pay

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:35 PM.


Advertisement
Log in to turn off these ads.