Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- If you receive a product, which already exists in the database, increase its quantity by the input quantity and if its price is different, replace the price as well.
- You will receive products’ names, prices and quantities on new lines. Until you receive the command “stocked”, keep adding items to the database. When you do receive the command “stocked”, print the items with their names, prices, quantities and total price of all the products with that name. When you’re done printing the items, print the grand total price of all the items.
- Note: The grand total is calculated, based on the latest price of the products.
- Constraints:
- -Until you receive “stocked”, the products come in the format: “{name} {price} {quantity}”.
- -The product data is always delimited by a single space.
- Output
- -Print information about each product, following the format:
- "{name}: ${price:F2} * {quantity} = ${total:F2}"
- -On the next line, print 30 dashes.
- -On the final line, print the grand total in the following format:
- “Grand Total: ${grandTotal:F2}”
- Examples:
- input:
- Beer 2.40 350
- Water 1.25 200
- IceTea 5.20 100
- Beer 1.20 200
- IceTea 0.50 120
- stocked
- output:
- Beer: $1.20 * 550 = $660.00
- Water: $1.25 * 200 = $250.00
- IceTea: $0.50 * 220 = $110.00
- ------------------------------
- Grand Total: $1020.00
Add Comment
Please, Sign In to add comment