Question
This program will reinforce our knowledge on basic C program control, arrays, and editing and compiling C programs. The objective of this assignment is to
This program will reinforce our knowledge on basic C program control, arrays, and editing and compiling C programs.
The objective of this assignment is to create a program that tallies a shopping list of items and displays each selected item, item cost, and total cost of all the selected items plus tax. The program will setup a simple sporting goods store with a few items and prices. The user will submit a shopping list in a textfile and submit it to the program as a command line argument.
Requirements:
The program will setup two arrays one for the store items and another for each price. The following table indicates the store items and prices:
Item: Price:
Cooler 32.75
Tent 158.23
Fishing Pole 23.25
Flashlight 15.35
Sleeping Bag 45.00
Camping Stove 61.55
Rope 4.25
Bottled Water 5.45
Bug Spray 3.25
Sunblock 7.90
First Aid Kit 12.45
Raincoat 22.35
The program will accept 1 command line argument that indicates the file name of a text-based file that contains a shopping list.
Each line of this file indicates the item to be purchased. The maximum length of the list is 20. The list of items will be zero based.
The program should process the shopping list and print the list out to the screen with each item and price on a separate row. At the end of the list the total cost with 5.5% tax added to it should be displayed.
You must make use of functions in this assignment. At least one of the functions must have parameters.
There must be arrays within the code.
Use good programming practice and check for array out of bounds errors and handle them appropriately
Example:
File: shoppingList.txt
1
2
2
3
3
3
2
ShoppingList.txt file is the actual list of items to be purchased 0 based. So the first digit 1 indicates a Tent, the digit 2 indicates a Fish Pole, etc If a digit 0 were present it would indicate a Cooler.
NOTE: A different list than the one above for testing the code.
Program Output:
Shopping List:
Tent $158.23
Fishing Pole $23.25
Fishing Pole $23.25
Flashlight $15.35
Flashlight $15.35
Flashlight $15.35
Fishing Pole $23.25
Total with tax: $289.10
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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