Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program Using C++ This lab simulates a database to store animal types and the animal type count. An abstract data type (ADT struct) and a

Program Using C++

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

sese enter an anina. type (none to stop): Cat 1. Add animals Animal: cat How many animal records would you like La stor(5 max): 4 1. Add animal(s) 2. Display animals 1. Quit Menu chuice: 1 the animal type's count; } Please enter an animal Lyric (nonr lu slapi): Dee Please enter an animal type (none to stop): Lion Enter the animal type's count: 2 Enter the animal lype's count: 5 Please enter an animal type (none to stop): man Enter the animal type's count: 5 2. Display 2. Quil. Menu choice: 2 count: 3 Aninal: dog round: 7 Animal: linn count: 5 Animal: nan count: 5 1. Add animal(s) 2. Display animals 1. Quit Menu choice

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_2

Step: 3

blur-text-image_3

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

What were the reasons for your conversion or resistance?

Answered: 1 week ago

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago