Programming Project 5 Using structure variables and arrays of structures solution

Problem: You are to create a program that will help a friend of yours keep track of the e-books that he has downloaded. You are to create a structure data type that contains the following properties (fields): title, author, publisher, copyright year, number of pages, and cost. The properties of title, author, and publisher should be stored as string objects and they all may contain spaces. You may assume that the author is stored in the format of “Lastname, Firstname”. Your program should employ the following functions:
a function that will prompt the user to enter values for all the fields for a single variable of the structure data type. This function should accept no parameters and should return a variable of the structure data type.
a function that will fill an array of this structure data type. This function should return the number of elements actually entered into the array and it should accept two parameters, an array of the structure data type and the maximum number of elements that can be stored in this array. This function should employ a loop that will continue as long as the user wants and there is still room in the array. The loop will call the function that prompts the user to enter the values for a single variable of the structure data type and will count how many array elements are actually entered.
a function to output all the values in the properties (fields) in a single variable of the structure data type. This function should not return anything and it should accept a single variable of the structure data type.
a function that will output all the elements of the array. This function should accept an array of structure data type and the number of elements actually stored in the array. This function should not return anything. This function should employ a loop that will call the function that outputs all the fields of a single structure variable.
a function to sort the array of structure variables ascending by author. Use one of the 3 sorting techniques presented in class. The sort should use the author field to determine how the array elements should interchanged. An entire structure variable should be swapped at one time (do not swap property by property).
a function to sort the array of structure variables ascending by title. Use one of the 3 sorting techniques presented in class. The sort should use the title field to determine how the array elements should interchanged. An entire structure variable should be swapped at one time (do not swap property by property).
a function to sort the array of structure variables descending by cost. Use one of the 3 sorting techniques presented in class. The sort should use the cost field to determine how the array elements should interchanged. An entire structure variable should be swapped at one time (do not swap property by property).
a function to sort the array of structure variables descending by number of pages. Use one of the 3 sorting techniques presented in class. The sort should use the number of pages field to determine how the array elements should interchanged. An entire structure variable should be swapped at one time (do not swap property by property).
a function that will calculate the total cost and average cost of the collection of e-books. The total cost and average cost should be transmitted back to the function call.[EKJ1]
Your main function should declare an array that will contain up to 50 structure variables. Then main should have a menu of utilities which include
filling the array;
output all the information in the array,
sort the array ascending by author,
sort the array ascending by title,
sort the array descending by cost,
sort the array descending by number of pages,
and calculate the total cost and average cost.
The menu should be implemented using a switch (no ifs are permitted in main) and should be inside a loop that will continue as long as wants to select another utility. When the user selects one of the sorting options, the function to display all the elements of the array should be called to display the sorted information. When the utility to calculate the total cost and average cost, these values should be sent back to main and main should output these values. Use each of the 3 sorting algorithms presented in class and posted on ANGEL at least once. Develop your own test data to test your program
Powered by