Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is for class person and customer import java.util.Scanner; public class Person { private String name = none; private int id = 0; Person(Person p){

this is for class person and customer

import java.util.Scanner; public class Person { private String name = "none"; private int id = 0; Person(Person p){ this.name = p.name; }

public Person() { } public static void person(String[] args) { Person p = new Person(); } public Person(String name, int id) { this.name = name; this.id = id; }

public String getName() { return name; } public int getID() { return id; } // setters here public void setName(String newName) { this.name = newName; } public void setId (int newId) { this.id = newId; } @Override public String toString() { return ("name=" + name + ", id=" + id); } }

public class Customer extends Person { private int custID = 0; public Customer() { super(); } public static void person(String[] args) { Customer cust = new Customer(); } public Customer(String name, int id, int custID) { super(name, id); this.custID = custID; } @Override public int getID() { return custID; } @Override public String toString() { return(super.toString() +", Customer ID: " + custID); } // other methods }

by using java language to write these codes

#3.

Write a test class called Test3 which will do the following which will read data from the terminal

a. Create a Customer object called cust with a given name, id and customer id from input

b. Assign that Customer object cust to a Person object p.

c. update the ID of that Person object.

d. print that ID

e. update the customer ID of that Person object.

f. print that customer ID

g. print both objects

#4.

A. Add a char attribute called gender to the Person class and add / modify relevant methods in this class.

B. Add a Boolean attribute called member to the Customer class. Then add / modify relevant methods in this class.

C. Write a test class called Test4 which will do the following and will read data from the terminal

a. Create and read 3 Person objects

b. Create and read 3 Customer objects

c. update the IDs of the Person objects.

d. Tally and print all male persons.

e. Tally and print all member customers

#5.

This question code is based on the updated versions of Person and Customer classes in question #4.

Write a test class called Test5 which will do the following and will read data from the terminal

a. Read n - the data size

b. Create an array of n Customer objects called cust.

c. Read n Customer objects into the array cust.

d. update a few customer IDs of these objects.

e. Tally and print all male customers.

f. Tally and print all member customers

g. Tally and print all female member customers

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions