• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

more java hw

Joined
Nov 26, 2006
Messages
620
Im not even sure what the objective of this assignment is. I have to create two classes one that uses the other and I think it has something to do with arrays. Anyway heres the instructions If you can make any sense of it let me know. Dont tell me how to do it just help me understand what the program is supposed to do.

Here are the instructions the professor gave..they are vague
 
Easy breezy:

- Create the HourlyEmployee class with the assigned instance variables and methods. You're defining characteristics of an HourlyEmployee and actions thereof.
- Import the class into your main class (the 'second' one [which should be created first anyway]).
- Instantiate those HourlyEmployees! And do the rest.

By the way, there's no real need for an array.
 
Email your professor.
Ha...I wish you knew this guy. Ive sent emails to him in the past and I never received responses. Not to mention the fact that he has a hard time explaining anything in english (not his native language). But I have class again tomorrow so ill bug him then. However he did say this is supposed to be one of the easiest projects...so as soon I know what Im actually supposed to make it should go together quickly.
 
Ok so i kind of understand, the first class is supposed to be used for creating objects (I dont know what to call them) that have the following variable attached to each one. example it creates "employee 1" with the following info about "employee 1", "Name:", "Position:","pay rate:", "hours worked this week". Then the second class is supposed use the toString method to print the output with should look something like this apparently.
Emp1 info
==================
Employee: Joe Blow
With position: instructor
With rate: 25.45
And hours: 50.0 (note make it so any -# are converted to 0)
Will get $1,399.75 (note this doesn’t count for the equality argument)

Emp2 info
==================
Employee: Joe Blow
With position: instructor
With rate: 25.45
And hours: 10.0
Will get $254.50

Emp1 = emp2 info
==================
True


Emp3 info
==================
Employee: bill Johnson
With position: manager
With rate: 10.0
And hours: 20.0
Will get: $200

After a raise emp1 info
==================
Employee: Joe Blow
With position: instructor
With rate: 26.45
And hours: 50.0
Will get $1,454.75

After a raise emp2 info
==================
Employee: Joe Blow
With position: instructor
With rate: 26.45
And hours: 10.0
Will get : $264.50
 
Hint - For loops for printing out arrays :).

Don't over think it. This assignment is very easy.
 
ok below is what I have so far, obviously its not complete but i think im heading in the right direction. Anyway on the first class (HourlyEmployee) im not sure if the variables are referenced correctly (for exp. i may have rate,aRate, and newRate in the wrong places) and I dont know how to make the toString method work. In the second one I cant compile the program becuase it says "cannot find symbol: HourlyEmployee". What am I doing wrong.

Code:
/**
 *Joseph Weaver
 *HourlyEmployee.java
 *Created on March 26, 2008, 6:59 PM
 */

package project5;


public class HourlyEmployee {
          
    private String name;
    private String position;
    private double rate;
    private double hours;
    private double pay;
    
    public void HourlyEmployee(String aName, String aPosition, double aRate, double aHours) {
        name = aName;
        position = aPosition;
        rate = aRate;
        hours = aHours;
    }
    
    public String getname() {
        return name;
    }
    public String getposition(){
        return position;
    }
    public double getrate(){
        return rate;
    }
    public double gethours(){
        return hours;
    }
    public double getpay(){
        if(hours > 40)
            pay = hours * rate * 1.5;
        else
            pay = hours * rate;
        return pay;
    }
    public void setname(String newName){
        name = newName;
    }
    public void setposition(String newPosition){
        position = newPosition;
    }
    public void setrate(double newRate){
        if (newRate < 0){
            newRate = 0;
        }
        rate = newRate;
    }
    public void sethours(double newHours){
        if (newHours < 0){
            newHours = 0;
        }
        hours = newHours;
    }
    public String toString(){
        return string("\n=======================" + "\nEmployee:" + name + "\nPosition:" + position
        + "\nPay Rate:" + rate + "\nHours Worked:" + hours + "\nPay:" + pay);
    }
}

Code:
/**
 *Joseph Weaver
 *HourlyEmployeeTest.java
 *Created on March 26, 2008, 6:59 PM
 */

package project5;
import project5.HourlyEmployee.*;

public class HourlyEmployeeTest {
    public HourlyEmployee emp1;
    public HourlyEmployee emp2;
    public HourlyEmployee emp3;
    public HourlyEmployee emp4;
    public HourlyEmployee emp5;
    
    public void main(){}
    /** Creates a new instance of HourlyEmployeeTest */
    public void HourlyEmployeeTest( String [] args ) {
        emp1 = new HourlyEmployee("Joseph Weaver", "Ruler of the Known Universe", 300,168);
        emp2 = new HourlyEmployee("Clone Joseph Weaver", "Personal Double", 8,168); 
    }
    
}
 
Back
Top