1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
12345 [234]
3 years ago
15

Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a con

structor 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.
Computers and Technology
1 answer:
Sophie [7]3 years ago
7 0

Answer:

Explanation:

The following code is written in Java. It creates the three classes as requested with the correct constructors, and getter/setter methods. Then the test class asks the user for all the information and creates the customer object, finally printing out that information from the object getter methods.

import java.util.Scanner;

class Person {

   String name, address, telephone;

   private void Person (String name, String address, String telephone) {

       this.name = name;

       this.address = address;

       this.telephone = telephone;

   }

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this.name = name;

   }

   public String getAddress() {

       return address;

   }

   public void setAddress(String address) {

       this.address = address;

   }

   public String getTelephone() {

       return telephone;

   }

   public void setTelephone(String telephone) {

       this.telephone = telephone;

   }

}

class Customer extends Person {

   String customerNumber;

   Boolean mailingList;

   public Customer(String s, Boolean mail) {

       super();

       this.customerNumber = customerNumber;

       this.mailingList = mailingList;

   }

   public String getCustomerNumber() {

       return customerNumber;

   }

   public void setCustomerNumber(String customerNumber) {

       this.customerNumber = customerNumber;

   }

   public Boolean getMailingList() {

       return mailingList;

   }

   public void setMailingList(Boolean mailingList) {

       this.mailingList = mailingList;

   }

}

class Test {

   public static void main(final String[] args) {

       Scanner in = new Scanner(System.in);

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

       String name = in.nextLine();

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

       String address = in.nextLine();

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

       String telephone = in.nextLine();

       System.out.println("Would you like to receive mail? y/n ");

       Boolean mail;

       if(in.nextLine() == "y") {

           mail = true;

       } else {

           mail = false;

       }

       Customer customer = new Customer("1", mail);

       customer.setName(name);

       customer.setAddress(address);

       customer.setTelephone(telephone);

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

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

       System.out.println("Telephone: " + customer.getTelephone());

       System.out.println("Wants to receive mail: " + String.valueOf(customer.getMailingList()));

   }

}

You might be interested in
Please choose the correct answer please tell fast​
pav-90 [236]

Answer:

the answer might be 2......

7 0
3 years ago
Project 15A - Math Application
vovikov84 [41]

Answer:

A simple php code for the following is given below:

Explanation:

interface Calculate {

 public function area($lenght,$width);

 public function perimeter($length,$width);

 public function surfaceArea($length_side_1,$length_side_2);

 public funcction volume($length, $width, $height):

}

interface Calculate2 {

 public function area($raidus);

 public function perimeter($radius);

 public function surfaceArea($radius);

 public funcction volume($radius):

}

Class Mian{

 

width=please Enter the value of width

height=please Enterr the value of height

length=please enter the value of length

lenght2=please enter the value of lenth of side 2

ridus= please enter the value of radius

    Circle = new circle()

    Rectangle = new rectangle()

}

Class Circle implements Calculate2{

 

public function area(){

area= pi*r

return area

}

public function perimeter(){

perimeter=2*pi*r

return perimeter

}

public function surfaceArea(){

surfacearea= pi*r*r

}

public function volume(){}

          area=area()

   volume=area*height

      return volume

}

Class Rectangle implements Calculate{

 

public function area(lenght,width){

 area= length * width

 return area

}

public function perimeter(lenght,width){

          perimenter=2(lenght+width)

          return perimeter

}

public function surfaceArea(length_side_1, withd right place){}

       surface_area 2*length_side_1  f*  length_side_2_

public function volume(){}

public surface volume(length,width,height)

 volume= length * width * height  

 return volume

}

7 0
3 years ago
The device that concerts one type of signal to another is what​
chubhunter [2.5K]

Answer:

Transducer is a type of device that converts one type of signal into another.

6 0
3 years ago
Daniel was appointed one of three princes over all 120 governors in the kingdom of: Belshazzar, Darius, Nebuchadnezzar, Jerioaki
Dovator [93]
The correct answer is DARIUS.
It is written in the bible in Daniel chapter 6 verses one and two: ' It pleased Darius to set over the kingdom 120 satraps, to be over the whole kingdom. And over these, three governors of whom Daniel was one, that the satraps might give accounts to them, so that the king would suffer no loss. 
5 0
3 years ago
Define computer on the basis of model.<br><br>Brainliest answer giveaway.<br>​
avanturin [10]

I found that,

On the basis of Model, computer is classified as: XT Computer (Extra Technology): It cannot support GUI based operating system. Its processing speed is 4.77 MHz and Intel 8080, 8086, 8088 series of microprocessors is used. PS/2 Computer: It is a laptop computer which is rechargeable and battery based system.

7 0
3 years ago
Other questions:
  • The trademarked name of the accepted standard for configuring wireless networks is _______________
    12·1 answer
  • What are some things you can do with labels in Word? Check all that apply. make them include audio print them on the inside of t
    13·1 answer
  • Write a program that will take an integer and add up each of the number’s digits, count the number of digits in the number, and
    13·2 answers
  • The section called Breaking Substitution Ciphers (p. 166) describes a "random substitution cipher," in which each letter of the
    11·1 answer
  • Which type of drawer has three dispensing modes: single-dose, multi-dose, and matrix?
    13·1 answer
  • Which of the following is something you need to keep an eye out for
    7·2 answers
  • What is the analysis stage in System development life cycle?
    12·1 answer
  • 2.3.4 CodeHS HTML Word Definitions
    10·1 answer
  • To use   ( 2 complement ) answer it (101101)2 – (1100)2 =   (                    )2
    12·1 answer
  • Is an automatic computer check to ensure that the data entered is sensible and reasonable.It does not check the accuracy of data
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!