Question
Using C++ programming, Chapter 11: Structures In this lab you will work with processing an array of structs. First define a struct called BookInfo. It
Using C++ programming,
Chapter 11: Structures
In this lab you will work with processing an array of structs. First define a struct called BookInfo. It should have 2 fields - a string to hold the title of a book, and a double to hold the price. Next define a second struct called Author. It should have 2 fields a string to hold the name of the author, and an array of BookInfo (with 3 elements) to store the three books the author has written.
In main, declare an array of Author structures with 3 elements. This array should be initialized to set all the string fields (the names and the book titles) to NONE, and the double fields (the prices) to zero. Remember initialization means to declare and assign values to the array all in one statement ( i.e. no for loops, etc.).
Next call a function from main with the following prototype:
void showInfo(Author a[], int size);
This function should printout the content of the array on the screen Next call a function from main with the following prototype:
void getInfo(Author a[], int size);
This function should allow the user to enter values into the array. If the user types NONE for one of the book titles, this means that the author has less than 3 books. The user should not be prompted to enter any more titles and price info for books by that author.
Next, call the showInfo function again from main to display the users input on the screen.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started