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 7683683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:51:03+00:00 2026-05-31T18:51:03+00:00

I’m working on a homework project that requires me to create an object from

  • 0

I’m working on a homework project that requires me to create an object from data entered by a user. I have a class called Person which takes the basic information, a class called Customer which extends the Person class and includes a customer number and a class called Employee which extends the Person class and returns a social security number.

I have pasted the code from my main program below. I’m a little confused on a couple of things. First when I’m collecting the information (first name, last name etc) amd I supposed to be accessing my Person class in there somehow?

Second I guess more plainly, how do I create the object? so far in all of the examples I have read online I find they seem to enter the information already like if I were to have it say

    Person firstName = new Person(Jack);

Although I am collecting the information from the user so I don’t see how to tell it like

    Person firstName = new Person (enter info from user here);

Finally and again this is a really dumb question but I have to create a static method that accepts a Person object.
To create the static method I’m assuming it is

    Public Static print()

but how do I tell it to print something from the person class? how does it know?

Most of my examples in the book include a class that contains all of the information instead of making the user enter it which is confusing because now I’m being told the user has the freedom to type what they want and I need to collect that information.

    import java.util.Scanner;
    public class PersonApp 
    {


public static void main(String[] args) 
{
    //welcome user to person tester
    System.out.println("Welcome to the Person Tester Application");
    System.out.println();

    Scanner in = new Scanner(System.in);


    //set choice to y
    String choice = "y";
    while (choice.equalsIgnoreCase("y"))
    {

        //prompt user to enter customer or employee
        System.out.println("Create customer or employee (c/e): ");
        String input = in.nextLine();

        if (input.equalsIgnoreCase("c"))
        {
            String firstName = Validator.getString(in, "Enter first name: ");
            String lastName = Validator.getString(in, "Enter last name: ");
            String email = Validator.getEmail(in, "Enter email address: ");
            String custNumber = Validator.getString(in, "Customer number: ");
        }

        else if(input.equalsIgnoreCase("e"))
        {
            String firstName = Validator.getString(in, "Enter first name: ");
            String lastName = Validator.getString(in, "Enter last name: ");
            String email = Validator.getEmail(in, "Enter email address: ");
            int empSoc = Validator.getInt(in, "Social security number: ");
        }


    }




    System.out.println("Continue? y/n: ");
    choice = in.next();


}

}

  • 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-31T18:51:05+00:00Added an answer on May 31, 2026 at 6:51 pm

    First, I observe that there isn’t a Person object. I assume you’ll get around to creating that, so I’m not going to concern myself too much with it.

    Insofar as actually getting the data, you’re halfway there. Depending on how you want to frame the Person object, you can create a new Customer or Employee object by passing the values which you received from the user.

    Customer customer = new Customer(firstName, lastName, email, custNumber);
    

    or

    Employee employee = new Employee(firstName, lastName, email, empSoc);
    

    Here’s the snippet of both:

    public class Person {
    
        public Person (String first, String last, String email) {
            // You'd fill in code here for handling the variables
        }
    
        // ...
    }
    
    public class Customer extends Person {
    
        public Customer (String first, String last, String email, String custNo) {
            super(first, last, email);
            // You'd fill in code here for handling the variables
        }
    
        // ...
    }
    
    public class Employee extends Person {
    
        public Employee (int social) {
            super(first, last, email);
            // You'd fill in code here for handling the variables
        }
    
        // ...
    }
    

    To print something from the Person class, using that static method (why? You could override toString() instead), you frame it such that your Person object has accessors to each of the fields relevant to a Person. This would mean you have a getFirstName(), getLastName(), and so forth, relevant to the object if it’s an employee or a customer. (I leave that as an exercise to you.)

    In that sense, one would then only require calls to those accessors to print the value.

    public static void print(Person p) {
    
        System.out.println(p.getFirstName()) + " " + p.getLastName()); // You can get the trend from here.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.