Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java coding assignment: Class name: Fishstore The Java Tropical Fish store is here to help you select the perfect tank for your tropical fish enjoyment.
Java coding assignment:
Class name: Fishstore
The Java Tropical Fish store is here to help you select the perfect tank for your tropical fish enjoyment. The first rule for setting up a nice, healthy fish tank is two gallons of water for every inch of fish in the tank. You must remember to consider the adult size of the fish. This means if you have adult fish, and each fish is long, you need to have at least an gallon tank.
fish x inches x gallonsfish
The second rule involves what sort of fish will live in the tank. If there are aggressive fish in the tank, then the tank should be sized times larger than the previous calculation. That is only an approximation, and in real life, you would have to carefully select your fish to make sure they get along well. But for this program, we will follow the two rules we just listed.
Fish tanks ONLY come in sizes in our store: and gallons. Your program should recommend to the user the next largest size that they need. For example, if you calculate that the user needs gallons for their fish, your program should recommend a gallon tank. If the fish would need a tank larger than gallons, print out that the store does not sell a large enough tank.
Start your program in main by declaring variables and writing a loop. Then ask the user to enter the information for the fish they expect to place in the new tank, then suggest the correct size tank.
For each fish, your code will ask the user:
What is the name of the fish type? for example: goldfish
What is the adult length of the fish type in inches? for example:
How many of this fish? for example:
Ask the user to enter all of this information and loop around for as many different fish types as the user wants. When the user enters done for the fish type, the loop will exit and stop collecting data.
Next ask your user if there are any aggressive fish in the group. Determine the best size tank based on the rules. If the user would need a tank bigger than gallons, tell the user that we dont carry any bigger tanks.
Write out a tank report, including whether or not any fish are aggressive, total length of fish, minimum required gallons and the appropriate tank. Here is a sample for Clown Loaches, which are long and Neon Tetras, which are long. None of the fish are aggressive:
Tropical Fish Store Tank Requirements
Aggressive: No
Total Fish Length:
Tank Size: gallons
Then ask the customer if heshe wants to calculate another fish tank. If the answer is yes, the program should run again. NOTE: This means that an outer loop is needed around the inner loop that collects the fish information! If the answer is no drop out of the loop, and show your customer a goodbye message.
Test Cases:
You can use these test cases to verify that your program is giving you correct results.
Test Case # fish type Clown Loach, number size
fish type Neon Tetra, number size
Correct output #
Tropical Fish Store Tank Requirements
Type of Fish Number Adult Size
Clown Loach
Neon Tetra
Aggressive: No
Total Fish Length:
Tank Size: gallons
Test Case # fish type Zebra Danios, number size
fish type Cherry Barb, number size
fish type AngelFish, number size aggressive
Correct output #
Tropical Fish Store Tank Requirements
Type of Fish Number Adult Size
Clown Loach
Neon Tetra
Aggressive: Yes
Total Fish Length:
Tank Size: gallons
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