Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8597011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:49:00+00:00 2026-06-12T00:49:00+00:00

package payroll3; /** * * @author Wiccan */ //employee class public class Employee {

  • 0
        package payroll3;

     /**
     *
     * @author Wiccan
     */
     //employee class
     public class Employee {

//fields
String name;
double rate;
double hours;
double gross;
double fedtax;
double statetax;
double deduction;
double netpay;

// constructor

public Employee(String name, double rate, double hours) {
    this.name = name;
    this.rate = rate;
    this.hours = hours;


}

    //returns net pay
    public double getNetPay() {
        return gross - deduction;
                }

        public String getName () {
        return name;
    }

    public void setName (String name) {
        this.name = name;
    }

    public double getHours() {
        return hours;
    }

    public void setHours(double hours) {
    this.hours = hours;
}

public double getRate() {
    return rate;
}

public void setRate(double rate) {
    this.rate = rate;
}

     public double getGross() {
        return hours*rate;
    }

    public void setGross(double gross) {
        this.gross = gross;
    }

    public double getFedtax() {
        return fedtax*gross;
    }

    public void setFedtax(double fedtax){
        this.fedtax = fedtax;
    }

    public double getStatetax() {
        return statetax*gross;
    }
    public void setStatetax(double statetax) {
        this.statetax = statetax;
    }

    public double getDeduction() {
        return statetax+fedtax;
    }

    public void setDeduction (double deduction) {
        this.deduction = deduction;
                }


    }

I am basically trying to get the variables within this class to function correctly. When I run it with it’s program I am supposed to get a net pay dollar amount. However, when I run it I get a 0.00 for a dollar amount though I should be getting 296.00 (approx depending on input). I was told that I am not calling the function to set the values. How do I go about doing so? I have tried many different ways and thought I had it right but I seem to always get the same output.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:49:01+00:00Added an answer on June 12, 2026 at 12:49 am

    You are mixing methods with simple setter/getters. You have an attribute netPay, but getNetPay() doesn’t return it; instead it calculates it from grossPay and deductions. The result of that calculation is returned to the caller, but not saved in the state of the object. You also have a setGross(), but getGross() doesn’t return that.

    Decide what are attributes of the class, and what should be calculated. You need to populate the attributes used for the deductions before you call getNetPay:

    employee.setFederalTax(0.13);
    

    (You are missing stateTax and fedTax to drive some of the other calculations). Then you can use those calculations:

    public double getNetPay() {
        return getGross() - getDeductions();
    }
    

    Anything that is calculated should not have a set function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

package pkgPeople; import java.io.Serializable; import java.text.DecimalFormat; public class Person implements Serializable{ private String name;
package pack; public class sample{ public static void main(String input[]) { NumberFormat numberFormat =
package org.study.algos; public class Study { public static void main(String[] args) { A a
package GC; import java.util.Scanner; public class main { public static void main(String args[]) {
package matlab; import com.mathworks.toolbox.javabuilder.*; import com.eigenface.Eigenface; public class Test { public static void main(String[]
package polynomial; /** * * @author Steven */ public class Polynomial { private float
package javaapplication1; import java.io.*; /** * * @author simon */ public class Main {
package com.test01; public class test01 { public static void main(String[] args) { System.out.println(hi); }
package myintergertest; /** * * @author Engineering */ public class Main { /** *
package employee; import employee.nidhin.staples; import java.util.*; import java.io.*; public class Employee { public static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.