Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a class named Person with fields for holding a person\'s name , address,

ID: 3790273 • Letter: D

Question

Design a class  named Person with fields for holding a person's name , address, and
telephone number (all as Strings ). Write a constructor that initializes all of these
values , and mutator and accessor methods for every field.

Next, design a class  named Customer, which inherits from the Person class . The Customer
class should have a String field for the customer number and a boolean field indicating
whether the customer wishes to be on a mailing list. Write a constructor that
initializes these values and the appropriate mutator and accessor methods for
the class 's fields.

Demonstrate the Customer class in a program that prompts the user to enter values
for the customer's name , address, phone number, and customer number, and then
asks the user whether or not the customer wants to recieve mail. Use this information
to create a customer object and then print its information.

Put all of your classes in the same file. To do this, do not declare them public.
Instead, simply write:

class Person { ... }
class Customer { ... }

SAMPLE RUN #1: java Driver

Enter·name·of·customer:Enter·address·of·customer:Enter·phone·number·of·customer:Enter·customer·number:Enter·yes/no·--·does·the·customer·want·to·recieve·mail?:

Customer:·

Name:·Julia·Stevens

Address:·77·Massachusetts·Ave·Cambridge,·MA·02139

Phone·Number:·617-777-7777

Customer·Number:·928734502

Recieve·Mail?:·false

My Code (what is wrong with the code) results with errors at bottom

import java.util.Scanner;

class Person

{

private String name;

private String address;

private String number;

public Person(String name, String address, String number)

{

        super();

        this.name = name;

        this.address = address;

        this.number = number;

}

    public String getName()

{

    return name;

}

public void setName(String name)

{

    this.name = name;

}

public String getAddress()

{

    return address;

}

public void setAddress(String a)

{

    address = a;

}

public String getNumber()

{

    return number;

}

public void setNumber(String number){

this.number = number;

}

}

class Customer extends Person

{

private String custNumber;

private boolean wants;

public Customer(String name, String address, String number, String         custNumber, boolean wants)

{

super(name, address, number);

this.custNumber = custNumber;

this.wants = wants;

}

public String getcustNumber()

{

    return custNumber;

}

public boolean isWants()

{

    return wants;

}

public void setWants(boolean wants)

{

   this.wants = wants;

}

}

class Driver

{

   public static void main(String[] args)

   {

        String name, address, number;

        String custNumber;

        String decide;

        boolean wants;

        Scanner keyboard = new Scanner(System.in);

        System.out.print("Enter name of customer:Enter address of customer:Enter phone number of customer:Enter yes/no -- does the customer want to recieve mail?:");

        name = keyboard.nextLine();

        address = keyboard.nextLine();

        number = keyboard.nextLine();

        custNumber = keyboard.nextLine();

        decide = keyboard.nextLine();

                    wants = decide.equals("yes");

        Customer Customer(name, address, number, custNumber,     wants); // creates new Customer Object.

        System.out.println("Customer: ");

        System.out.println("Name: " + one.getName());

        System.out.println("Address: " + one.getAddress());

        System.out.println("Phone Number: " + one.getNumber());

        System.out.println("Receive Mail?: " + one.isWants());

   }

}

Expected Result:


Enter·name·of·customer:Enter·address·of·customer:Enter·phone·number·of·customer:Enter·customer·number:Enter·yes/no·--·does·the·customer·want·to·recieve·mail?:

Customer:·

Name:·Julia·Stevens

Address:·77·Massachusetts·Ave·Cambridge,·MA·02139

Phone·Number:·617-777-7777

Customer·Number:·928734502

Recieve·Mail?:·false

Your Code's Actual Result:


Enter·name·of·customer:Enter·address·of·customer:Enter·phone·number·ocustomer:Enter·yes/no·--·does·the·customer·want·to·recieve·mail?:Customer:·

Name:·Julia·Stevens

Address:·77·Massachusetts·Ave·Cambridge,·MA·02139

Phone·Number:·617-777-7777

Receive·Mail?:·false

Given the following was entered from the keyboard:
Stacy Jones
200 Eastern Pkwy, New York, NY 11238
718-638-5000
359921457
yes

Expected Result:


Enter·name·of·customer:Enter·address·of·customer:Enter·phone·number·of·customer:Enter·customer·number:Enter·yes/no·--·does·the·customer·want·to·recieve·mail?:

Customer:·

Name:·Julia·Stevens

Address:·77·Massachusetts·Ave·Cambridge,·MA·02139

Phone·Number:·617-777-7777

Customer·Number:·928734502

Recieve·Mail?:·false

Explanation / Answer

Driver.java

import java.util.Scanner;
class Person {
   private String name;
   private String address;
   private String number;
   public Person(String name, String address, String number)
   {
   super();
   this.name = name;
   this.address = address;
   this.number = number;
   }
   public String getName()
   {
   return name;
   }
   public void setName(String name)
   {
   this.name = name;
   }
   public String getAddress()
   {
   return address;
     
   }
   public void setAddress(String a)
   {
   address = a;
     
   }
   public String getNumber()
   {
   return number;
   }
   public void setNumber(String number){
   this.number = number;
   }

}
class Customer extends Person {
   private String custNumber;
   private boolean wants;
   public Customer(String name, String address, String number, String custNumber, boolean wants)
   {
   super(name, address, number);
   this.custNumber = custNumber;
   this.wants = wants;
   }
     
   public String getcustNumber()
   {
   return custNumber;
   }
   public boolean isWants()
   {
   return wants;
   }
   public void setWants(boolean wants)
   {
   this.wants = wants;
   }
}
class Driver {

       public static void main(String[] args) {
           String name, address, number;
   String custNumber;
   String decide;
   String decision;
   boolean wants = false;
   Scanner keyboard = new Scanner(System.in);
   System.out.print("Enter name of customer:Enter address of customer:Enter phone number of customer:Enter yes/no -- does the customer want to recieve mail?:");
   System.out.println("Customer:");
   System.out.print("Name:");
  
   name = keyboard.nextLine();
   System.out.print("Address:");
   address = keyboard.nextLine();
   System.out.print("Phone Number:");
   number = keyboard.nextLine();
   System.out.print("Customer Number:");
   custNumber = keyboard.nextLine();
   System.out.print("Recieve Mail?:");
   decide = keyboard.nextLine();
  
   Customer Customer(name, address, number, custNumber,wants); // creates new Customer Object.
   System.out.println("Given the following was entered from the keyboard:");
   System.out.println(one.getName());
   System.out.println(one.getAddress());
   System.out.println(one.getNumber());
   //wants = decide.equals("yes");
  
   if(one.isWants()==true)
   decision="Yes";
   else
   decision="No";
   System.out.println(decision);

       }

   }

______________________

Output:

Enter name of customer:Enter address of customer:Enter phone number of customer:Enter yes/no -- does the customer want to recieve mail?:Customer:
Name:Stacy Jones
Address:200 Eastern Pkwy, New York, NY 11238
Phone Number:718-638-5000
Customer Number:359921457
Recieve Mail?:false
Given the following was entered from the keyboard:
Stacy Jones
200 Eastern Pkwy, New York, NY 11238
718-638-5000
No

_____________Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote