Question: Task Description Write a program that allows a user to create and store new rabbytes. Each rabbit is identified by a unique name. The program

Task Description
Write a program that allows a user to create and store new rabbytes. Each rabbit is identified by a unique name. The program also allows the user to enter a rabbit's age.
Main menu
The program prompt of the main menu looks like:
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
If the user inputs 1,2,3 or 0, it runs the corresponding function. Otherwise, the prompt is simply printed again. See example 1.
We recommend you create a function for each menu option.
1. Create a Rabbit
Upon inputting 1, the program will then print the prompt
Input the new rabbit's name:
If the user enters a new name, the program returns to the menu and prints the main prompt.
Otherwise, the program prints
That name is already in the database.
Input the new rabbit's name:
and repeat this until the user inputs a new name. See example 2.
2. Input Age of a Rabbit
Upon inputting 2, the program will then print the prompt
Input the rabbit's name:
If the user inputs a name (e.g. rabbie) that is already in the database, the program asks for the rabbit's age:
Input the rabbit's name:
rabbie
Input rabbie's age:
2
It then returns to the main menu and prints the main prompt.
If the user inputs a name that does not exist, the program prints
That name is not in the database.
Input the rabbit's name:
until an existing name is provided. See example 3.
We assume that:
- the age input is an integer,
- the user will only pick option 2 if a rabbit has already been created,
- the user can freely set the age of a rabbit, even if it already has one. It will be updated.
3. List Rabbytes
Upon inputting 3, the program will then print
Rabbytes:
rabbie (42)
not_rabbie (Unknown)
if two rabbytes, rabbie and not_rabbie, have been created before, and if rabbie's age (42) has been input, and not_rabbie's age hasn't. See example 4.
Display the rabbytes in the order they were created.
Examples
User inputs are in bold font below.
Example 1
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
foo
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
0
Example 2
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
1
Input the new rabbit's name:
undercover_robbie
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
1
Input the new rabbit's name:
undercover_robbie
That name is already in the database.
Input the new rabbit's name:
robbie_the_rabbit
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
0
Example 3
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
1
Input the new rabbit's name:
rabbie
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
2
Input the rabbit's name:
bob
That name is not in the database.
Input the rabbit's name:
rabbie
Input rabbie's age:
2
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
0
Example 4
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
3
Rabbytes:
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
1
Input the new rabbit's name:
rabbie
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
1
Input the new rabbit's name:
not_rabbie
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
2
Input the rabbit's name:
rabbie
Input rabbie's age:
42
==================================
Enter your choice:
1. Create a Rabbit.
2. Input Age of a Rabbit.
3. List Rabbytes.
0. Quit.
==================================
3
Rabbytes:
rabbie (42)
not_rabbie (Unknown)
==================================
Enter

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!