Question: Please follow instructions and use C++, please This lab simulates a database to store animal types and animal type count. A programmer-defined data structure and

Please follow instructions and use C++, please

This lab simulates a database to store animal types and animal type count. A programmer-defined data structure and a vector are used for data storage (required).

The input, output, and interface (use the same menu) are the same as for Lab 0. Rather than using parallel arrays to store the data you will use a vector of structures. By using a structure, the data will be stored together as a unit. Vectors are dynamic sequence structures that can grow as needed. You will create an empty vector that you will then add animals to.

  1. Define a programmer defined data structure (struct) to store the animal type and animal count. Name the struct Animal and define the animal type member variable as a string, and the animal count member variable as an integer. Initialize the animal type to empty string, and the animal count to zero.

  1. Create an empty vector (zero elements, no size) to store the data for one to five animals. The vector will be of type Animal (using your programmer defined Animal structure). Name the vector animals. See step 3 for more information.

Note: You are not allowed to use array notation to add new elements to the vector. You can only use the .push_back function.

  1. Input the types(s) and counts of one to five animals. Input should cease at the fifth entry (use the Vector's size function to check the current number of records), or when the user enters any form of the word none before five entries have been made. Use a programmer defined function for input which is called when the add animal menu option is chosen.

Note:

  • The animal types should be able to accept one or more words for the animal type. Assume at least one animal will be entered. (use getline)
  • All variables should be initialized.
  • All numeric data must be validated.
  • Data entry for animal counts is not allowed without a corresponding animal type.
  • Your program should accept any version of the word none: Uppercase, lowercase, or mixed case. Convert the entry to lowercase before testing. You will need to include the cctype library for this. To accomplish this, use your toLowerCase function.

string toLowerCase(string)

  1. Display the animal type and count for each animal in the vector. Use a programmer-defined function for the output which is called when the Display animal menu option is chosen. You are allowed to use array notation or an iterator to access the vector elements.

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 Databases Questions!