Question
Part a: Write a program that creates an ArrayList of pets .An item in the list is either a Dog or a Cat. For each
Part a: Write a program that creates an ArrayList of pets .An item in the list is either a Dog or a Cat. For each pet, enter its name and type (c for cat and d for dog). Stop the input when the string STOP is entered for the name. After the input is complete, output the name and type for each pet in the list. Part b: Modify part b and this time group the output by printing out the names of all cats first and then the names of all dogs. Part c: Modify the Dog class to include a new instance variable weight (double) and the Cat class to include a new instance variable coatColor (string). Add the corresponding accessors and mutators for the new instance variables. Modify part b by inputting additional information appropriate for the type. First you input name and type, as before. If the type is a cat, then input its coat color. If the type is a dog, then input its weight. After the input is complete, output the name, type, and coat color for the cats and the name, type, and weight for the dogs. Suppose you have a list of Dog and Cat objects then find the average, minimum, and maximum weight of dogs.c++ code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started