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

  • Home
  • SEARCH
  • 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 4007228
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:36:28+00:00 2026-05-20T08:36:28+00:00

I’m a college student doing a Java homework. I’ve created this program that allows

  • 0

I’m a college student doing a Java homework. I’ve created this program that allows user to enter a job information.

The problem is that my program doesn’t return information entered.

I look at my program for a while, but I know it’s something simple I’m missing.

public class Employee 
{
    String name;             // Employee name
    String employeeNumber;   // Employee number
    String hireDate;         // Employee hire date
    int shift;                   // Employee shift
    double payRate; 

    public void setEmployeeNumber(String e)
    {
       if (isValidEmpNum(e))
       {
          employeeNumber = e;
       }
       else
       {
          employeeNumber = "";
       }
    }

    public Employee(String name, String e, String hireDate, double payRate, int shift)
    {
       this.name = name;
       this.setEmployeeNumber(e);
       this.hireDate = hireDate;
       this.payRate = payRate;
       this.shift = shift; 
    }

    public Employee()
    {
       name = "";
       employeeNumber = "";
       hireDate = "";
    }

    public void setpayRate(double payRate)
    {
       this.payRate = payRate;
    }

    public double getpayRate()
    {
       return payRate;
    }

    public void setshift(int shift)
    {
       this.shift = shift;
    }

    public int getshift()
    {
       return shift;
    }


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

    public void setHireDate(String hireDate)
    {
       this.hireDate = hireDate;
    }

        public String getName()
    {
       return name;
    }

    public String getEmployeeNumber()
    {
       return employeeNumber;
    }

    public String getHireDate()
    {
       return hireDate;
    }

    private boolean isValidEmpNum(String e)
    {
       boolean status = true;

       if (e.length() != 5)
          status = false;
       else
       {
         if ((!Character.isDigit(e.charAt(0)))  ||
            (!Character.isDigit(e.charAt(1)))   ||
            (!Character.isDigit(e.charAt(2)))   ||
            (e.charAt(3) != '-')                ||
            (!Character.isLetter(e.charAt(4)))  ||
            (!(e.charAt(4)>= 'A' && e.charAt(4)<= 'M')))
          {
             status = false;
          }
       }
       return status;
    }
    public String toString()
    {
       String str = "Name: " + name + "\nEmployee Number: ";

       if (employeeNumber == "")
       {
          str += "INVALID EMPLOYEE NUMBER";
       }
       else
       {
          str += employeeNumber;
       }

       str += ("\nHire Date: " + hireDate);
       return str;
    }  
}

I declared this in another class.

import javax.swing.JOptionPane;

public class ProductionWorkerDemo extends Employee 
{
    public static void main(String[] args)
    {
       String name;             // Employee name
       String employeeNumber;   // Employee number
       String hireDate;         // Employee hire date
       int shift;                    // Employee shift
       double payRate;               // Employee pay
       String str;
       String str2;


       name = JOptionPane.showInputDialog("Enter your name: ");

       employeeNumber = JOptionPane.showInputDialog("Enter your employee number: ");

       hireDate = JOptionPane.showInputDialog("Enter your hire date: ");

       str = JOptionPane.showInputDialog("Enter your shift: ");

       payRate = Double.parseDouble(str);

       str2 = JOptionPane.showInputDialog("Enter your payrate: ");

       payRate = Double.parseDouble(str2);

       ProductionWorkerDemo pw = new ProductionWorkerDemo();

        System.out.println();
        System.out.println("Name: " + pw.getName());
        System.out.println("Employee Number: " + pw.getEmployeeNumber());
        System.out.println("Hire Date: " + pw.getHireDate());
        System.out.println("Pay Rate: " + pw.getpayRate());
        System.out.println("Shift: " + pw.getshift());

    }
}
  • 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-05-20T08:36:29+00:00Added an answer on May 20, 2026 at 8:36 am

    You are setting the employee information on local variables only. You are not passing them to the ProductionWorkerDemo nor it’s super class Employee.

    1. You don’t need to extend the Employee with the ProductionWorkerDemo as the ProductionWorkerDemo is not an Employee. You can just remove the extends Employee text.

    2. You’re not passing the variables to the Employee. You’ve created a constructor in the Employee class that takes them all so you can use it

      Employee pw = new Employee(name, employeeNumber, hireRate, payRate, shift);

    3. Now you’ll notice that you haven’t asked for the shift.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.