Your cart is empty!
What to do: This assignment is called "Compute the invoice grand total and tax due"
You must develop everything on the Drexel tux.cs.drexel.edu servers
Requirements
Create a C program, named a1.c, to solve the following problem.
You are the developer of an online shop and you are working with the shopping cart module that holds the customer's online order. The online order contains multiple products that may be shipped to different states. Your job is to create a C program that reads the order in the shopping cart and calculates both the grand total due and the total tax due.
The order / shopping cart information should be made available to your program via a command line argument. An example order file has been provided with the assignment. The format of the file should be
productName, quantity, unitPrice, state
Each line item represents the sale of a product at a given quantity and unit price that will ship to a given state. Your program should assume that there could be spaces, between any token in the file, meaning that attributes may be surrounded by spaces to the left or to the right (see the example file provided). You should eliminate leading and trailing spaces from the tokens.
Each product in the order may be shipped to a different address and therefore it is subject to a different sales tax. The tax rate information should be made available to your program via a second command line argument. An example file tax_rate.txt has been provided with the assignment. The format of each line in the file is
state,state_abbreviation,sales_tax
For example
Pennsylvania,PA,6.000%
Please note that for this file there are no trailing or leading spaces surrounding the tokens, and there is no need to write code to remove them.
There should be two ways of invoking your program
a1
and
a1 order_file tax_rate_file invoice_file
Your program should read the input files order_file and tax_rate_file, make all necessary calculations and generate an output file named invoice_file.
If there are no command line arguments, the program should assume the following default file names
order.txt
tax_rate.txt
invoice.txt
The program should read the order file and tax rate file. For each product it should compute the subtotal (price * quantity) as well as the tax due for that product. It should also provide the grand total for the entire order (sum of all the subtotals) as well as the total tax due (sum of all taxes). Your output should be written to a file and could look like this:
Product Price Quantity State Tax Subtotal
----------------------------------------------------------------
Knife 125.00 1 PA 7.50 132.50
Colander 25.95 2 NJ 3.44 55.34
..
Total Tax Due: XXXXX
Grand Total: YYYY
Tips
· order.txt
· Knife, 1, 125, PA
· Colander ,2 ,25.95 ,NJ
· Cutting Board, 3 , 29.99 , NY
· Measuring Cup,4,15,PA
· Measuring Spoon,5,10,NY
· Grater,6,20.99,PA
· Blender,7,100,PR
·
·
· tax_rate.txt
· Alabama,AL,4.000%
· Alaska,AK,0.000%
· Arizona,AZ,5.600%
· Arkansas,AR,6.500%
· California,CA,7.250%
· Colorado,CO,2.900%
· Connecticut,CT,6.350%
· Delaware,DE,0.000%
· District of Columbia,DC,6.000%
· Florida,FL,6.000%
· Georgia,GA,4.000%
· Hawaii,HI,4.000%
· Idaho,ID,6.000%
· Illinois,IL,6.250%
· Indiana,IN,7.000%
· Iowa,IA,6.000%
· Kansas,KS,6.500%
· Kentucky,KY,6.000%
· Louisiana,LA,4.450%
· Maine,ME,5.500%
· Maryland,MD,6.000%
· Massachusetts,MA,6.250%
· Michigan,MI,6.000%
· Minnesota,MN,6.875%
· Mississippi,MS,7.000%
· Missouri,MO,4.225%
· Montana,MT,0.000%
· Nebraska,NE,5.50%
· Nevada,NV,6.85%
· New Hampshire,NH,0.000%
· New Jersey,NJ,6.625%
· New Mexico,NM,5.125%
· New York,NY,4.000%
· North Carolina,NC,4.750%
· North Dakota,ND,5.000%
· Ohio,OH,5.750%
· Oklahoma,OK,4.500%
· Oregon,OR,0.000%
· Pennsylvania,PA,6.000%
· Puerto Rico,PR,11.500%
· Rhode Island,RI,7.000%
· South Carolina,SC,6.000%
· South Dakota,SD,4.500%
· Tennessee,TN,7.000%
· Texas,TX,6.250%
· Utah,UT,4.850%
· Vermont,VT,6.000%
· Virginia,VA,4.300%
· Washington,WA,6.500%
· West Virginia,WV,6.000%
· Wisconsin,WI,5.000%
· Wyoming,WY,4.000%
The blurred section contains detailed solutions to the Assignment or Exam above.
Patient Initials: M J Person giving information: []Patient [] __medical surrogate_____(relationship to patient) Date of Birth: 23/4/1980...
See AnswerReflection Health care professionals play a critical role in enhancing health care delivery and quality care outcomes. As they accomplish this mand...
See AnswerNURSING DIAGNOSIS #1 The Problem Statement Related To (R/T) As Evidenced By (AEB) NURSING DIAGNOSIS #2 The Problem Statement Related To (R/T) ...
See Answer