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 receive 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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

java

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 receive 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
java Driver
Enter name·of•customer:Julia Stevens-
Enter·address of customer:77.Massachusetts·Ave Cambridge, ·MA · 02139-
Enter phone·number·of·customer:617-777–7777-
Enter customer:number:928734502
Enter yes/no·--•does·the customer:want to receive mail?:no-
Customer:·d
Name: Julia Stevens-
Address: 77 · Massachusetts Ave Cambridge, MA·02139
Phone Number::617-777-7777-
Customer Number:·928734502-
Receive Mail?:·false-
Transcribed Image Text: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 receive 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 java Driver Enter name·of•customer:Julia Stevens- Enter·address of customer:77.Massachusetts·Ave Cambridge, ·MA · 02139- Enter phone·number·of·customer:617-777–7777- Enter customer:number:928734502 Enter yes/no·--•does·the customer:want to receive mail?:no- Customer:·d Name: Julia Stevens- Address: 77 · Massachusetts Ave Cambridge, MA·02139 Phone Number::617-777-7777- Customer Number:·928734502- Receive Mail?:·false-
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education