Question
How do you fix this program in Java? In the test program, if you enter n to go to rest of program doesn't work The
How do you fix this program in Java? In the test program, if you enter "n" to go to rest of program doesn't work
The program doesn't break to go on with rest of the program
ZooAnimals.java
/** * * Program creates Zoo Animals and calculates weekly food needed in pounds * * @author * */ abstract class ZooAnimals { private String sound; private String name; private int numberOfLegs; private double weight; /** * * Method defines Zoo animal characteristics. */ public ZooAnimals(String sound, String name, int numberOfLegs, double weight) { this.sound = sound; this.name = name; this.numberOfLegs = numberOfLegs; this.weight = weight; } /** * * Method gets sound of Zoo Animal. */ public String getSound() { return sound; } /** * * Method sets the sound of Zoo Animal. */ public void setSound(String sound) { this.sound = sound; } /** * * Method gets name of Zoo Animal. */ public String getName() { return name; } /** * * Method sets the name of Zoo Animal. */ public void setName(String name) { this.name = name; } /** * * Method gets Number of Legs of Zoo Animal. */ public int getNumberOfLegs() { return numberOfLegs; } /** * * Method sets Number of Legs of Zoo Animal */ public void setNumberOfLegs(int numberOfLegs) { this.numberOfLegs = numberOfLegs; } /** * * Method gets Zoo Animals weight. */ public double getWeight() { return weight; } /** * * Method sets Zoo Animals weight. */ public void setWeigth(double weight) { this.weight = weight; } /** * * Method calculates Weekly Food Needed in Pounds. */ public abstract double calculateWeeklyFoodNeededPounds(); @Override /** * Animal Characteristics listed of Zoo Animals. */ public String toString() { return "ZooAnimals [sound= " + sound + ", name=" + name + ",numberOfLegs=" + numberOfLegs + ",weight=" + weight + "]"; } } class Tiger extends ZooAnimals { private String tigerType; /** * * Method describes Tiger characteristics. */ public Tiger(String sound, String name, int numberOfLegs, double weight, String tigerType) { super (sound, name, numberOfLegs, weight); this.tigerType = tigerType; } /** * * Method gets Tiger's type. */ public String getTigerType() { return tigerType; } /** * * Method sets Tiger's type. */ public void setTigerType(String tigerType) { this.tigerType = tigerType; } @Override /** * Method calculates Weekly Food Needed in Pounds. */ public double calculateWeeklyFoodNeededPounds() { return getWeight() * 0.15; } @Override /** * Method describes characteristics of Tiger. */ public String toString() { return "Tiger [tigerType= " + tigerType + ",sound=" + getSound() + ",name=" + getName() + ",numberOfLegs=" + getNumberOfLegs() + ",weight=" + getWeight() + "]"; } } class Gorilla extends ZooAnimals { private String gorillaType; /** * * Method descirbes characteristics of Gorilla. */ public Gorilla (String sound, String name, int numberOfLegs, double weight, String gorillaType) { super(sound, name, numberOfLegs, weight); this.gorillaType = gorillaType; } /** * * Method gets Gorilla Type. */ public String getGorillaType() { return gorillaType; } /** * * Method sets Gorilla Type. */ public void setGorillaType(String gorillaType) { this.gorillaType = gorillaType; } @Override /** * Method calculates Weekly Food Needed in Pounds. */ public double calculateWeeklyFoodNeededPounds() { return 0.5 * super.getWeight(); } @Override /** * Method prints out Gorilla characteristics. */ public String toString() { return "Gorilla [gorillaType=" + gorillaType + ", sound=" + super.getSound() + ", name=" + super.getName() + ", numberOfLegs=" + super.getNumberOfLegs() + ",weight=" + super.getWeight() + "]"; } }
ZooAnimalTestProgram.java
import java.util.ArrayList; import java.util.Scanner; /** * This Program prompts the user in a loop to create Zoo Animals. * * @author * */ public class ZooAnimalTestProgram { public static void main (String[] args) { ArrayList
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