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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:35:32+00:00 2026-05-31T11:35:32+00:00

I asked a question earlier on this same project but I’m still having issues

  • 0

I asked a question earlier on this same project but I’m still having issues that I can’t get through.
The project has a Person class, Validator class, Customer class, and Employee class. The Person class stores data about the person (name, email) the Customer class extends the person class and adds a customer number to the toString method. The Employee class also extends the Person class and extends a social security number to the toString method by overriding it.

At the bottom of the page I am trying to print the toString methods from my customer class OR my employee class. I want to make sure I am printing the right class based on what the user selected (if they are entering customer info or employee info)

The assignment specifically says “To print the data for an object to the console, this application should use a static method named print that accepts a Person object.”

I think I have it started but I’m getting all kinds of red lines under what I have coded. Starting around the

    public void toString()

line down towards the bottom.

I’m starting to think I am getting deeper into trouble by looking it up online so if someone can help me through it I would be greatful. My book doesn’t show much on how to do this and all of the examples it shows seem to create the input and then print it but I’m trying to get the input from a user so I’m getting confused.

    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: ");
            Customer customer = new Customer(firstName, lastName, email, custNumber);


        }

        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: ");
            Employee employee = new Employee(firstName, lastName, email, empSoc);
        }

    public void toString()
    {
        Person p;
        p = c;
        System.out.println(c.toString());

        p = e;
        System.out.println(e.toString());
    }

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


}
}
    }
  • 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-31T11:35:33+00:00Added an answer on May 31, 2026 at 11:35 am

    You can’t define methods inside another method. The way you have the brackets, toString is defined inside main, which is illegal.

    Also, you can’t have toString return void, since it overrides the toString method from Object. Rename your method or have it return a String.

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

Sidebar

Related Questions

i had asked earlier about the same kind of question but that was in
I asked this question earlier. I am intrigued by std::set but I have another
This question was asked earlier by someone else but never answered: MKAnnotation - Map
You may think this question is like this question asked on StackOverflow earlier. But
I asked this question earlier but I was very vague and a lot of
I have asked this question earlier today but I didn't provide enough information and
I asked this question earlier but regarding another programming languages. Let's say I have
I asked this question earlier but I didn't express myself correctly. If I have
I asked this question earlier, but I'm missing one important thing. I have a
I asked a question about this earlier but received no responses, so I'm trying

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.