Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Program please help This final program will use an array of structures . Arrays of structures are just like any other array. AND THEY

C++ Program please help

This final program will use an array of structures. Arrays of structures are just like any other array. AND THEY ARE PASSED EXACTLY THE SAME WAY. Don't over-think this part. Make a structure. Make an array of structures. Pass the array around.

Here's what I want you to do: Write a small program that creates a structure. And then an array of strictures. Initialize the array with some data. Then call a function and pass it the array. Inside the function, run through a for loop and output the structures, line by line.

Functional Requirements:

A menu-driven program that allows my friend, the dog trainer, to store information about his dogs including dog name, age, breed, weight, food, and amount to feed.

Offer the trainer the following menu that loops until they choose option 5.

1. Input a dog's information.

2. Edit a dog's information

3. Search for a dog and display

4. Display all dogs

5. Exit

-------------------------------------

Dog data:

Name (string - up to 10 characters, may not be blank)

Age (int, >=0 )

Breed (string - up to 10 characters, may not be blank)

Weight (float >=0)

Food Type (string - up to 10 characters, may not be blank)

Amount to Feed in Cups (float >=0)

Above main(), create a structure that will hold the information listed above. Then inside of main() create an array of 10 structures. Each structure in the array will represent a different dog.

----------------------------------------

Programming Requirements:

Menu Option 1: Pass the array of structures to a function that inputs and validates dog data for ONE DOG. Make sure that you are counting the number of dogs as you go so that you don't allow more then 10 dogs to be input.

Menu Option 2: Pass the array of structures to a function that prompts the user for which dog to edit and then prompts the user for what field to edit. Accept and validate the edit.

Option 3. Pass the array of structures to a function that prompts the user for which dog to display and then displays that dog's information.

Option 4. Pass the array of structures to a function that displays all dogs information AND the total amount of food which would be needed. (which your program will calculate).

Option 5. Exist the program.

Make sure to design modular code. If you have code that is repeated then call one function to handle it.

----------------------------------------

Option 4 Sample Output

******************************************************************************************************************************************************

Dog Information

******************************************************************************************************************************************************

Name Age Breed Weight Food Amount

Buddy 12 Labrador 112 Nutro 1.5 cups

Nina 10 Scotty 35 Purina 0.5 cups

Total Food Required: 2.0 cups

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

More Books

Students also viewed these Databases questions