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:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
If the user inputs or it runs the corresponding function. Otherwise, the prompt is simply printed again. See example
We recommend you create a function for each menu option.
Create a Rabbit
Upon inputting 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
Input Age of a Rabbit
Upon inputting the program will then print the prompt
Input the rabbit's name:
If the user inputs a name eg 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:
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
We assume that:
the age input is an integer,
the user will only pick option 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.
List Rabbytes
Upon inputting the program will then print
Rabbytes:
rabbie
notrabbie Unknown
if two rabbytes, rabbie and notrabbie, have been created before, and if rabbie's age has been input, and notrabbie's age hasn't. See example
Display the rabbytes in the order they were created.
Examples
User inputs are in bold font below.
Example
Enter your choice:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
foo
Enter your choice:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
Example
Enter your choice:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
Input the new rabbit's name:
undercoverrobbie
Enter your choice:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
Input the new rabbit's name:
undercoverrobbie
That name is already in the database.
Input the new rabbit's name:
robbietherabbit
Enter your choice:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
Example
Enter your choice:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
Input the new rabbit's name:
rabbie
Enter your choice:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
Input the rabbit's name:
bob
That name is not in the database.
Input the rabbit's name:
rabbie
Input rabbie's age:
Enter your choice:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
Example
Enter your choice:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
Rabbytes:
Enter your choice:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
Input the new rabbit's name:
rabbie
Enter your choice:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
Input the new rabbit's name:
notrabbie
Enter your choice:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
Input the rabbit's name:
rabbie
Input rabbie's age:
Enter your choice:
Create a Rabbit.
Input Age of a Rabbit.
List Rabbytes.
Quit.
Rabbytes:
rabbie
notrabbie Unknown
Enter
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
