Question
C++ PROGRAMMING PLEASE HELP & THANK YOU!!! WILL UPVOTE You've just been hired to implement a shopping cart for an online retailer, Sprockets R Us.
C++ PROGRAMMING PLEASE HELP & THANK YOU!!! WILL UPVOTE
You've just been hired to implement a shopping cart for an online retailer, "Sprockets R Us". The existing system already has the product price, shipping, and tax information available in an external file. The company has requested that the shopping cart read in the product information from the external file, ask the user how many items they wish to purchase, and then write out an order receipt.
The product information is stored in the product_public.txt file. A second example is provided as well: product_public2.txt This file has the following format:
price_per_individual_unit sales_tax_percentage_rate shipping_min_1 flat_shipping_rate1 shipping_min_2 flat_shipping_rate2 shipping_min_3 flat_shipping_rate3 free_shipping_min
The first line gives the price of an individual Sprocket. The second line gives the sales tax percentage to be applied. The next three lines list three shipping rates. The first value is the minimum price and the second value is the corresponding shipping fee. The last line gives the minimum amount to qualify for free shipping.
Your first task is to read in these values from the external file and store all the values in variables with an appropriate data type.
- First, determine the product total by multiplying the price per unit by quantity ordered.
- Next, determine the shipping fee based on #1. The amounts correspond to the The public file has a shipping table as follows:
If Total Amount Is Between Then Shipping Fee Is [shipping_min_1, shipping_min_2) ($0.00, $9.98] $25.99 [shipping_min_2, shipping_min_3) [$9.99, $29.98] $19.99 [shipping_min_3, free_shipping_min) [$29.99, $99.98] $14.99 [free_shipping_min, infinity) [$99.99, $) $0.00 - Next, compute the subtotal of product total (#1) plus shipping fee (#2).
- Now determine the sales tax amount by multiplying the subtotal from #3 by the sales tax percentage. When computing the amount, if a fraction of a penny remains then use the half round up rule (round up if >= 5, otherwise round down).
- Compute the subtotal of product total (#1) plus shipping fee (#2) plus sales tax (#4).
- If the subtotal from #5 is not an even dollar amount ($X.00), then ask the user if they would like to make a donation and round their total up to the nearest dollar. If they say yes, then compute the donation amount necessary to round the subtotal up to the nearest dollar amount.
- Finally, compute the grand total by adding the subtotal from #5 with the donation amount from #6. Display this final amount to the user.
Each step of the calculation will be printed to an external file named receipt.txt. The receipt MUST match the following formatting with example amounts based off of the public_product.txt file
An Example is shown:
Welcome to Sprockets-R-Us!
We sell round sprockets, square sprockets, and triangle sprockets.
The cost of a single sprocket is $1.99.
How many sprockets do you wish to order?
> 5
Thank you for your order of 5 sprockets! One moment while we prepare your receipt... Do you wish to make a donation to the Human Fund? (Y/N)
> Y
Thank you for your order. Your total is $39.00.
-----------------------------
Sprockets-R-Us Order Receipt
-----------------------------
Price Per Unit: $ 1.99
Quantity Ordered: 111
Unit Subtotal: $ 220.89
-----------------------------
Shipping Fee: $ 0.00
-----------------------------
Sales Tax ( 6.75%):$ 14.91
-----------------------------
Donation? N
=============================
Grand Total: $ 235.80
=============================
- All dollar amounts are displayed to two decimals.
- All dollar amounts are right aligned with the decimal point aligned. You can assume all amounts will be less than $100,000.
- Sales Tax Rate is listed as a percentage. You can assume the rate will be less than 100% and greater than 0%.
THANK YOU
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started