Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write C program for solving the following tasks: a. Declare a struct Node for a Bookshop which will take as elements: an integer item number

image text in transcribed

Write C program for solving the following tasks: a. Declare a struct Node for a Bookshop which will take as elements: an integer item number (call it item_num), a char item name (call it item_Name[30]), a float price (call it item_price) and of course a pointer for the next node. k. In main(), reduce by 5 the price of any item in the bookshop having a value greater than 50. 1. Print the new linked list. m. Ask the user in main() to enter an item number from the list to be deleted. n. Create and call a function called SearchAndDelete that checks if the item number exists in the list and delete it. Otherwise, provide the message "The item number you gave does not exist in the list to the user. b. Create a function that declares and initializes the linked list by asking the user how many items to include. c. Create a function called Display to print the linked list data d. Create a function called Insert that inserts a new node at the end beginning of the linked list you created in part b. e. In main() ask the user to enter data for the new item, use these values when calling the function you wrote in part d, in order to add these details into the linked list. f. Use the Display function to print the linked list again after insertion of new items. g. Create a function called CountOccurrences that calculates and returns the number of the occurrences of an item number typed by the user. Check the sample output. h. Create a function called Lowest which will return the item number having the lowest price in the supermarket. i. Call the function Lowest in main() and print the result. j. Create a function called Average that calculates and returns the average of all number of the books in the list. Enter List Size: 3 Enter your Element: 3 Novels 51 List is: ->(3 Novels books, price: 51.0 each) Enter your Element: 2 Scientific 49 List is: ->(2 Scientific books, price: 49.0 each)->(3 Novels books, price: 51.0 each) Enter your Element: 3 Historic 52 List is: ->(3 Historic books, price: 52.0 each)->(2 Scientific books, price: 49.0 each)->(3 Novels books, price: 51.0 each) Type a number of an item and I will find for you the number of its occurrences in the linked list: 3 The number 3 appears in the list 2 times The lowest number out of all book items in the list is: 2 The average of all numbers of books in the list is 2.67 The updated list with the deducted by 5 price of those books more than 50 KWD is List is: ->(3 Historic books, price: 47.0 each)-> (2 Scientific books, price: 49.0 each)->(3 Novels books, price: 46.0 each) Type a number of item and I will delete it for you from the linked list: 2 The updated List is: -> (3 Historic books, price: 47.0 each) ->(3 Novels books, price: 46.0 each) Process returned (Oxo) execution time: 66.421 s Press any key to continue

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions