Implement a simplified grocery Webshop in C programming language. Create a structure that contains a set of products and their number. A product has a name, price and quantity. Create two instances of this structe. The first represents the webshop store and the other represents a cart. Print a menu for the user that contains the following items: Load webshop store from a file\ This operation loads the content of the store from a text file. The filename should be read from the keyboard. The file contains the product name, price and quantity in the following format:Apple 100 42 Orange 130 59 Raspberry 231 17 ... Write the content of the store to a file\ Read a filename from the user and write the content of the store to that file using the file format above. Insert an item to cart\ The cart contains the items that a customer wants to buy. Read a product name and the quantity from the keyboard and put this information to the cart. The price of the product should be fetched from the store. Get the price of cart\ This operation prints the sum of the products' prices in the cart. Buy the products\ When this option is chosen, then the content of the cart is subtracted from the store. If a certain amount of product is not available in the store then print an error message to the user which tells how many products are missing. For example if the user needs 10 apples and the store contains only 8, then the following message should be printed: "2 apples are missing". In this situation, subtract the available amount of products from the store. Make sure that a product can't have negative quantity in the store. Exit the program\ This option finishes the program execution. The program keeps displaying this menu to the user until they choose the exit option. The content of the store and the cart should be stored in an array on the heap memory. In case the array is full, you should allocate a bigger array and remove the previous one. Implement the operations in separate function. For example, the inserter function gets a cart or a store, and a product as parameter. This product is inserted to the given cart or store. If the product is already inserted, then the quantity should be increased instead of inserting the product twice. Separate the program to multiple translation units. The first translation unit contains the program control and the other contains the implemented types and their operations.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Implement a simplified grocery Webshop in C programming language.

Create a structure that contains a set of products and their number. A product has a name, price and quantity. Create two instances of this structe. The first represents the webshop store and the other represents a cart.

Print a menu for the user that contains the following items:

  1. Load webshop store from a file\ This operation loads the content of the store from a text file. The filename should be read from the keyboard. The file contains the product name, price and quantity in the following format:Apple 100 42 Orange 130 59 Raspberry 231 17 ...
  2. Write the content of the store to a file\ Read a filename from the user and write the content of the store to that file using the file format above.
  3. Insert an item to cart\ The cart contains the items that a customer wants to buy. Read a product name and the quantity from the keyboard and put this information to the cart. The price of the product should be fetched from the store.
  4. Get the price of cart\ This operation prints the sum of the products' prices in the cart.
  5. Buy the products\ When this option is chosen, then the content of the cart is subtracted from the store. If a certain amount of product is not available in the store then print an error message to the user which tells how many products are missing. For example if the user needs 10 apples and the store contains only 8, then the following message should be printed: "2 apples are missing". In this situation, subtract the available amount of products from the store. Make sure that a product can't have negative quantity in the store.
  6. Exit the program\ This option finishes the program execution.

The program keeps displaying this menu to the user until they choose the exit option.

The content of the store and the cart should be stored in an array on the heap memory. In case the array is full, you should allocate a bigger array and remove the previous one.

Implement the operations in separate function. For example, the inserter function gets a cart or a store, and a product as parameter. This product is inserted to the given cart or store. If the product is already inserted, then the quantity should be increased instead of inserting the product twice.

Separate the program to multiple translation units. The first translation unit contains the program control and the other contains the implemented types and their operations.

AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Lists
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education