Question
I need this program in Java. A complete program please. Program Requirements Create an abstract class named ZooAnimal A private String data field sound A
I need this program in Java. A complete program please.
Program Requirements
Create an abstract class named ZooAnimal
A private String data field sound
A private String data field name
A private int data field numberOfLegs
A private double data field weight
An all-args constructor that creates a ZooAnimal for all private fields.
getter/setter methods for all private fields.
An abstract method calculateWeeklyFoodNeededPounds, returns double
create a toString method that prints all of the fields
Create a Tiger class. It extends ZooAnimal
a private String data field tigerType
An all-args constructor that creates a Tiger for all private fields.
getter/setter methods for all private fields.
a tiger needs to eat 15% of it's weight each week. Use this for calculateWeeklyFoodNeededPounds
create a toString method that prints all of the fields
Create a Gorilla class. It extends ZooAnimal
a private String gorillaType
An all-args constructor that creates a Tiger for all private fields.
getter/setter methods for all private fields.
a gorilla needs to eat 50% of it's weight each week. Use this for calculateWeeklyFoodNeededPounds
create a toString method that prints all of the fields
Create a Test Program
Write a test program that prompts the user in a loop to create ZooAnimals.
Add each ZooAnimal to an Arraylist.
create a method that prints and calculates the cost of feeding the animals assume that gorilla food costs $2 lbs and tigers cost $4 lbs -- call this method after gathering the information below
Ask the following question;
What Type of Zoo Animal, enter T for Tiger or G for Gorilla?
{type}'s name?
{type}'s sound?
{type}'s number of leg?
{type}'s weight?
{type}'s type:
Enter another Zoo, enter Y for yes?
Use an Enhanced for loop and for each ZooAnimal print out the ToString and the calculateWeeklyFoodNeededPounds
Example output:
What Type of Zoo Animal, enter T for Tiger or G for Gorilla? T Tigers name? Billy Tigers sound? ROAR Tigers number of legs? 4 Tigers Weight? 569 Tigers type? Bengal Enter another Zoo Animal, enter Y for yes? Y What Type of Zoo Animal, enter T for Tiger or G for Gorilla? G Gorillas name? Joe Gorillas sound? ROAR Gorillas number of legs? 2 Gorillas Weight? 445 Gorillas type? Mountain Enter another Zoo Animal, enter Y for yes? n Tiger [tigerType=Bengal, sound=ROAR, name=Billy, numberOfLegs=4, weight=569.0] Gorilla [gorillaType=Mountain, sound=ROAR, name=Joe, numberOfLegs=2, weight=445.0] The cost to feed the Tiger Billy for a week: $341.40 The cost to feed the Gorilla Joe for a week: $445.00
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