Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please write the code according to the given samples Description In this homework, you will develop a console-based application that simulates the functioning of a

please write the code according to the given samples
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Description In this homework, you will develop a console-based application that simulates the functioning of a basic supermarket checkout system. The program is designed to handle two key functionalities: input and storage of supermarket items, and processing of a customer's shopping list. The simulation will involve managing a dynamic inventory of items and calculating the total cost of a customer's purchases, including tax. Your program should start by prompting the user to input product details, including a unique QR code(which can contain both numbers and letters), the product name, and its price. This input phase continues until the user enters "END", signaling the completion of the inventory input. Following the inventory setup, the program then prompts for the shopping list. This list consists of the items the customer intends to purchase, identified by their unique QR code, along with the quantity of each item. As with the inventory input, the shopping list input concludes when the user enters "END". The core functionality of your program involves matching the items from the shopping list with those in the inventory. For each item on the shopping list, your program should search the inventory by QR code, calculate the total price for the requested quantity, and display this information in a structured and readable format. If an item from the shopping list does not exist in the inventory, the program should notify the user and ask for a valid item QR code. Lastly, the program calculates the total cost of all items in the shopping list, including an 18% Value Added Tax (VAT). The output will display each item's name, quantity, individual cost, and the total cost including VAT, all formatted for easy readability. This assignment will test your ability to work with vectors, strings, and structured data in C++, as well as your understanding of basic programming constructs such as loops, conditional statements, and functions. It will also challenge you to think about efficient data management and user interaction in a console application. Inputs, Flow of the Program, and Outputs: Supermarket Item Database: Users input item details ( QR, name, price) repeatedly until "END" is entered. Shopping List Input: Users input shopping items ( QR, quantity) until "END" is entered. Structures Used: Supermarket Item: A struct to store item details from the item database, including QR code (string), name (string), and price (double). Shopping List Item: A struct for the shopping list, containing the item QR code (string) and quantity (int). Program Flow: Supermarket Item Database Processing: Each item entered is stored in a vector of Supermarket Item structs. Shopping List Processing: The program searches for each item QR code in the shopping list within the supermarket item database. If found, it calculates the total cost based on the quantity. Total Calculation: Calculates subtotal and 18% VAT on all valid shopping list items. Outputs: For each valid shopping list item, the program displays its name, quantity, and total cost in alformatted manner. The total price of each item will be calculated according to the number of items and its price. In other words, TotaL_Price =Item_Price * Item_Count. Input Entry and Input Check - Supermarket item QR codes will be unique, and prices will be in double format. You can assume that all entered QR codes will be distinct and all prices will be valid double values. - QR cocie can have both numbers and uppercase letters. The shop list may contain lowercase letters, your program should handle it. - The shop list can contain wrong QR codes, you should handle it. - Number of items bought will be an integer. Assume only integers will be entered. Some Hints Utilizing getline for Input: - Use getline to read each line of input when entering supermarket item details. This ensures you can capture the entire line, including spaces within item names. - Separating QR Code, Name, and Price: After using getline, the line will contain the QR code, item name, and price. The first space in the line marks the end of the QR code, and the ' $ ' symbol indicates the end of the item name. - getline(cin, line); - Use 'substr' and 'find' methods from the string class for parsing the input. - Remember to convert the price to a double. For this conversion, the 'ptof' function from 'strutils. h ' can be used. Using setw for Formatted Output: - It's crucial to use setw to align and format the output correctly, as the students' outputs must match the expected format exactly. When displaying each item from the shopping list, use setw to align the item name, quantity, and price. For example: - setw(5) should precede the item name to ensure proper spacing. - setw(3) should be used before displaying the item quantity. - For the item price, setw(31 - Item.name) can be used. This dynamic width adjustment ensures that the prices are right-aligned correctly. - For displaying the VAT and total, use setw with specific values to align the numbers on the right. For instance: - Use " VAT (18%):" to use setw. - For the total, use " Total:"

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

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions

Question

2. Darwins notes in biology.

Answered: 1 week ago