1 Replies - 168 Views - Last Post: 16 February 2013 - 07:42 AM Rate Topic: -----

#1 starterkit123  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 16-February 13

Payroll Class Getting Value Of 0 No Matter What I Enter

Posted 16 February 2013 - 07:41 AM

Hi, for some reason I'm getting a value of 0 as my output.

import java.util.Scanner;	//Needed for scanner class.

public class Payroll{

	private String EmployeeName;
	private int IDnumber;
	private double HourlyPayRate;
	private double HoursWorked;
	private double GrossPay;
	
	/**
		Constructor
		@param Name The name to store in EmployeeName.
		@param ID The ID to store in Employee ID number.
	*/
	public Payroll(String Name, int ID)
	{
		EmployeeName = Name;
		IDnumber = ID;
	}
	public String getEmployeeName()
	{
		return EmployeeName;
	}
	public int getIDnumber()
	{
		return IDnumber;
	}
	public void setHourlyPayRate(double HourlyRate)
	{
		HourlyPayRate = HourlyRate;
	}
	public double getHourlyPayRate()
	{
		return HourlyPayRate;
	}
	public void setHoursWorked(double hoursWorked)
	{
		HoursWorked = hoursWorked;
	}
	public double getHoursWorked()
	{
		return HoursWorked;
	}
	public double getGrossPay()
	{
		return HourlyPayRate * HoursWorked;
	}
}




import java.util.Scanner;	//Needed for Scanner class.

public class PayRollTest
{
public static void main(String[] args){
        
        
	{
		String EmployeeName;
		int IDnumber;
		double HoursWorked;
		double HourlyPayRate;
		double GrossPay;
		
		//Create a Scanner object for keyboard input.
		Scanner keyboard = new Scanner(System.in);
		
		//Get the employee's name.
		System.out.println("Enter an employee's name: ");
		EmployeeName = keyboard.nextLine();
		
		//Get the employee's ID.
		System.out.println("Enter the employee's ID " );
		IDnumber = keyboard.nextInt();
		
		//Get the number of hours worked by the employee.
		
		
		//Get the hourly pay rate of the employee.
		System.out.println("Enter the hourly pay rate for this employee: ");
		HourlyPayRate = keyboard.nextDouble();
                
               
		System.out.println("Enter the number of hours worked: ");
HoursWorked=keyboard.nextDouble();



		//Create a payroll object, passing EmployeeName and IDnumber
		// as arguments to the constructor.
		Payroll pay = new Payroll(EmployeeName, IDnumber);
                
                pay.setHourlyPayRate(HourlyPayRate);


		//Get the Gross Pay of the employee.
		System.out.println("The gross pay of " + EmployeeName + " is: $" + pay.getGrossPay());
	}


}
}



Is This A Good Question/Topic? 0
  • +

Replies To: Payroll Class Getting Value Of 0 No Matter What I Enter

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: Payroll Class Getting Value Of 0 No Matter What I Enter

Posted 16 February 2013 - 07:42 AM

Try not to double post. Be patient after pushing the "Post" button. Topic locked.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1