Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please follow the instructions to complete the code in C++ Please This lab simulates a database to store animal types and the animal type count.

Please follow the instructions to complete the code in C++ Please

This lab simulates a database to store animal types and the animal type count. An abstract data type (ADT struct) and a dynamically allocated array of the ADT must be used for record storage. The program must use a menu for adding animal records and displaying a list of animal records. The menu must also have an option to exit the program. Data entry and data display must be done from within the required functions. Do not place any source code for data entry or data display directly in the main function.

  1. You must define your ADT with two fields to store the type of animal (cat, dog, lion, tiger, etc.) and the animal type count. The animal type should have a default value of none, and a default count of 0.

  1. You must create a dynamically allocated array using your ADT as the data type for the array. Query the user for the number of records. The database must store a minimum of two records and a maximum of five records. Do not allow the user to specify a record count less than the minimum or more than the maximum.

  1. Add animal records:

You must prototype, define, and use a function for inputting the animal records. Input the animal types(s) and animal counts for no more than the total number of records specified by the user. Input should cease after the last record has been entered, or when the user enters the word none. Not all records must be input at once.

  • Do not store none in the array

  • Do not allow the user to enter the animal count if the animal type has not been entered.

  • The add animal function must only allow animals to be added if the database is not full. You will need to track the number of animal records stored. Hint: use a static variable in the function

Ex. If only one animal is added the first time, selecting the add menu option should allow more animals to be added on subsequent attempts until all records are full. Do not overwrite existing records.

    • Your program should accept any version of the word none during input: Uppercase, lowercase, or mixed case. Convert the entry to lowercase before testing. Use the toLowerCase function you wrote during the class programming activity.
  1. Display the animal records:

You must prototype, define, and use a function to display the current list of animal records (animal types and counts). Each animal type must have a corresponding count. The output must be neat and readable.

Notes:

  • The animal types must be able to accept one or more words for the animal type. Ex. Red Panda
  • All variables must be initialized.
  • All input data must be validated.
  • Data entry for animal type counts is not allowed without a corresponding animal type.
  • The dynamically allocated array must be deleted, and the pointer must be reset to nullptr before program execution finishes.

image text in transcribed

X 11 C:\Users\mikel Downloads\laboSolution (7).exe How many animal records would you like to store(5 max): 4 _1. Add animal(s) 32. Display animals 23. Quit Menu choice: 1 Please enter an animal type (none to stop): cat Enter the animal type's count: 44 Please enter an animal type (none to stop): fish Enter the animal type's count: 22 Please enter an animal type (none to stop): none 1. Add animal(s) 2. Display animals 3. Quit Menu choice: 2 Animal: cat count: 44 Animal: fish count: 22 1. Add animal(s) 2. Display animals 3. Quit X 11 C:\Users\mikel Downloads\laboSolution (7).exe How many animal records would you like to store(5 max): 4 _1. Add animal(s) 32. Display animals 23. Quit Menu choice: 1 Please enter an animal type (none to stop): cat Enter the animal type's count: 44 Please enter an animal type (none to stop): fish Enter the animal type's count: 22 Please enter an animal type (none to stop): none 1. Add animal(s) 2. Display animals 3. Quit Menu choice: 2 Animal: cat count: 44 Animal: fish count: 22 1. Add animal(s) 2. Display animals 3. Quit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions

Question

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago