Starting from:

$25

Using structure variables and arrays of structures problem 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”. Purpose: Program will keep track of a maximum of 50 e-books that the user has downloaded. Program will use a structure data type to keep track of the following properties of the e-books: title, author, publisher, copyright year, number of pages, and cost. Title, author, and publisher will be stored as strings and may contain spaces. Author will be stored as "Lastname, Firstname”. Users will be able to enter data on multiple e-books and the program will output all data and sort the data by ascending: author,title; descending: cost, pages. Additionally, the total cost and average cost of the e-books should be output. Input: Program will allow the user to enter up the properties listed above for 50 e-books. Additionally the user will select which sorting option they wish to view, and will enter when they wish to exit the program. Output: Program will prompt the user for e-book data until the user wishes to stop entering data. Program will then output a menu to view different sortings of the e-book data. The program will be able to output the sorted data for each e-book. Processing: 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. 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 Attach your source code file and your output file to the same submission to the appropriate drop box by 11:00 pm on 12/11/15. Follow the Assignment guidelines posted on ANGEL. Do not use pointers and do not include any library files that you do not use.

More products