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]
2 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]2 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
Give an example of an input device, an output device, a storage device, and a networking device.
eduard
Peripheral device<span>, </span><span>also known as </span><span>peripheral, </span>computer peripheral,<span>input-output device, </span><span>or </span>input/output device<span>, any of various devices (including sensors) used to enter information and instructions into a </span>computer<span> for storage or processing and to deliver the processed data to a human operator or, in some cases, a </span>machine<span> controlled by the computer. Such devices make up the </span>peripheral<span>equipment of modern </span>digital computer<span> systems.</span>
8 0
3 years ago
All NATE specialties are offered at two levels, A. journeyman and master. B. installation and service. C. apprentice and journey
Rainbow [258]

Answer:

D. heating and air conditioning.

Explanation:

NATE is a business that declares specialists in the heating system, ventilation, and air conditioning industry.

5 0
2 years ago
Help a brotha out..................
Sveta_85 [38]

Answer:

highlight a cell in column A; place your cursor on the border of the cell so it turns into a two sided arrow and drag

Explanation:

y

3 0
2 years ago
Write a program that lets a maker of chips and salsa keep track of their sales for five different types of salsa they produce: mi
natali 33 [55]

Answer:

Using C++ to solve the problem as given below

Explanation:

#include<iostream>

#include<string.h>

using namespace std;

int main()

{

string salsa_name[5]={"mild","medium","sweet","hot","zesty"};

int jar_sale[5]={0,0,0,0,0};

int i;

int total=0;

int high=0;

int high_index=0;

int low=0;

int low_index=0;

int temp=0;

for(i=0;i<5;i++)

{

while(temp<=0)

{

cout<<"enter the number of jars sold for "<<salsa_name[i]<<" ";

cin>>temp;

if(temp<=0)

cout<<"invalid data. please try again\n";

}

jar_sale[i]=temp;

temp=0;

}

cout<<"name\t jars sold\n";

cout<<"\n---------------------------\n";

for(i=0;i<5;i++)

{

cout<<" "<<salsa_name[i]<<"\t\t"<<jar_sale[i]<<"\n";

}

low=jar_sale[0];

for(i=0;i<5;i++)

{

total=total+jar_sale[i];

if(jar_sale[i] >= high)

{

high_index=i;

high=jar_sale[i];

}

if(jar_sale[i]<=low)

{

low_index=i;

low=jar_sale[i];

}

}

cout<<"\n total sale : "<<total;

cout<<"\n high seller : "<<salsa_name[high_index];

cout<<"\n low seller : "<<salsa_name[low_index];

}

5 0
3 years ago
Is this code object-oriented, or is it procedural? what clues in the code itself did you use to determine what kind of code it i
Katen [24]

An Object-Oriented code or coding refers to a technique of programming that utilizes the identification of classes of objects that are closely tied to the functions with which they are related.

<h3>What is a Procedural Oriented Code?</h3>

This refers to a kind of programming language that utilizes a step-by-step method so as to break down a task into a set or a collection of factors or variables and routines or sub-routines using a set of instructions that are sequential.

Objects in programming refer to a type of abstract data that has a state and behavior. It is a specific instance of a class.

A class in programming is a templated definition of the techniques and variables of a certain type of object.

<h3>What are some of the principles and structures of coding?</h3>

There are 10 principles of coding. Some of them are:

  1. Keep it simple
  2. Separate concerns
  3. Document your Code etc.

Some of these principles can be used in normal day-to-day activity and even in business. item 1 for instance can be used during communication.  Effective communication is more effective when it is kept very simple.

It is to be noted that the code referenced in the question is unavailable hence the general answer.

Learn more about Object-Oriented Code at:
brainly.com/question/4560494

3 0
2 years ago
Other questions:
  • Below is a chart representing portions of resumes from 3 applicants. Which best explains the applicants careers?
    11·1 answer
  • What human activity would cause a decrease in the population of another species? (The action of humans would impact one species,
    9·1 answer
  • To use the Save As command, click on the __________tab to open the backstage view.
    13·1 answer
  • Plagiarism occurs when writers
    14·2 answers
  • Help me out here pleaseeeee
    9·2 answers
  • Why does brainly keep saying “oops... something went wrong! Try again”
    7·2 answers
  • Which of the following is true of information systems?
    15·1 answer
  • which of the following cells can't be recarged? A. Electrode cell B. wet cell C. primary cell D. storage cell
    13·1 answer
  • Rewritable (write, erase, write again) is known as _______.
    7·1 answer
  • Perceptron simplest definition
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!