Question: Objective: Using what you have learned on array search and file I/O you will create a system that allows a user to shop for items,
Objective: Using what you have learned on array search and file I/O you will create a system that allows a user to shop for items, add them to a shopping cart, and process their order.
Details:
- At the start of your program read in the product information from the ProductData.csv file. You must use seekg and seekp to read in the file contents. Do not read in the whole line and separate the data on commas, you will be counted off if you do this.
- The product data must be stored in a multidimensional array (Note: There is exactly 145 items in the product list. You can assume I will not add or remove any items to the product list. So, for this assignment the array size (4 x 145) will be fixed to the total number of products). If you store in single dimensional arrays you will be counted off. Hint: Do not store redundant data.
- After storing the data in your arrays, you must ask the user what products they would like to buy. You will take as input item numbers (Note: The user should be allowed to select up to as many as the 145 items).
- Implement a search function to search your multidimensional array to find the product information You can use any search function you would like. If the item is not found in the array then you need to output and error message. When the item is found you should output the item name and cost.
- Ask the user how many of the item the would like. Check their input against the available qty on hand. Inform the customer if there is not enough available and have them reenter a qty. If there is none available then tell the user we are currently out of stock of the item. After entering a qty that is allowed you must add the item to their shopping cart.
- You must store all the items that the user inputs and keep collecting input from the user until they indicate they are done.
- If the user enters a 0 when asked about entering a product then you know they are done.
- Collect the following user information:
Name
Street Address
City, State Zip code
- You will output to the screen and to a file name invoice.txt a formatted invoice that looks like the following.
Customer Name: John Doe
Customer Address: 123 Sesame Street
Fakeville, TX 12345
Item Number Item Name Qty Unit Cost Total
------------------------------------------------------------------------------------------------------------------------------------------
Item Number 1 Product Name 1 1.99 1.99
.
Item Number X Product Name X 10 1.00 10.00
------------------------------------------------------------------------------------------------------------------------------------------
Total: $11.99
ProductData.csv contents -
Item Number,Name,Cost,Qty 12735,Product 001,02.09,121 69703,Product 002,03.64,069 15964,Product 003,10.75,085 24286,Product 004,13.51,197 67671,Product 005,08.42,030 97041,Product 006,14.67,045 60290,Product 007,19.72,030 24600,Product 008,03.02,197 44023,Product 009,11.26,139 46045,Product 010,18.32,018 49814,Product 011,18.95,140 36883,Product 012,05.07,072 48356,Product 013,09.15,005 52384,Product 014,07.21,190 89405,Product 015,15.03,184 46021,Product 016,09.53,089 92497,Product 017,15.65,164 80218,Product 018,19.50,093 19677,Product 019,04.95,058 14187,Product 020,08.96,066 41657,Product 021,09.68,054 52930,Product 022,09.39,126 39728,Product 023,04.95,155 69103,Product 024,03.37,156 67987,Product 025,04.97,199 20709,Product 026,15.73,089 28202,Product 027,12.33,075 36794,Product 028,20.49,100 88532,Product 029,16.88,059 57113,Product 030,07.87,122 70196,Product 031,01.86,129 64123,Product 032,16.90,048 17713,Product 033,11.31,177 64376,Product 034,06.06,162 58470,Product 035,10.07,137 36209,Product 036,12.03,081 40586,Product 037,16.79,096 17639,Product 038,18.81,034 20996,Product 039,12.29,082 86850,Product 040,09.57,037 81873,Product 041,05.01,104 51395,Product 042,01.93,094 30499,Product 043,08.73,014 54726,Product 044,06.30,166 10868,Product 045,13.79,034 38838,Product 046,01.54,052 51610,Product 047,19.63,168 41297,Product 048,04.83,028 12958,Product 049,01.81,165 14083,Product 050,15.98,189 47164,Product 051,16.32,007 61867,Product 052,05.35,198 78026,Product 053,03.11,006 41810,Product 054,19.98,021 77347,Product 055,09.87,193 13509,Product 056,16.72,195 20264,Product 057,09.03,005 43562,Product 058,15.34,131 22570,Product 059,09.80,044 24555,Product 060,05.68,078 24531,Product 061,02.59,038 87464,Product 062,07.54,024 78707,Product 063,10.34,089 21149,Product 064,06.80,073 97042,Product 065,18.64,074 25547,Product 066,20.93,124 86993,Product 067,09.20,007 32311,Product 068,12.34,110 15015,Product 069,06.81,189 32059,Product 070,15.44,112 95358,Product 071,10.95,090 28939,Product 072,03.18,115 96810,Product 073,19.35,197 84077,Product 074,13.54,075 10049,Product 075,17.67,071 34889,Product 076,12.70,149 69344,Product 077,18.30,082 15305,Product 078,18.75,147 37579,Product 079,19.28,114 71311,Product 080,11.41,065 17829,Product 081,05.14,169 59995,Product 082,17.65,161 32350,Product 083,10.14,200 75511,Product 084,20.59,052 18000,Product 085,01.84,198 56301,Product 086,10.17,135 45848,Product 087,03.22,178 76987,Product 088,14.62,188 31541,Product 089,17.96,047 21662,Product 090,17.00,083 11017,Product 091,02.14,097 40523,Product 092,18.67,077 28909,Product 093,06.76,058 10397,Product 094,13.78,054 27383,Product 095,09.07,109 60972,Product 096,20.95,023 83662,Product 097,09.15,120 92111,Product 098,15.84,039 27941,Product 099,16.77,015 67816,Product 100,11.65,128 28661,Product 101,05.14,056 73865,Product 102,18.83,169 99177,Product 103,18.13,110 37649,Product 104,16.49,106 63239,Product 105,15.31,027 86930,Product 106,06.03,037 96978,Product 107,17.74,090 84248,Product 108,04.12,007 10595,Product 109,08.37,070 76059,Product 110,17.36,170 39253,Product 111,20.65,038 71576,Product 112,16.79,149 97543,Product 113,18.16,019 61324,Product 114,16.87,081 98221,Product 115,03.56,190 25749,Product 116,20.81,096 60203,Product 117,02.75,147 53852,Product 118,06.27,063 81745,Product 119,01.39,135 66109,Product 120,20.89,163 23560,Product 121,17.18,068 77213,Product 122,08.13,092 30379,Product 123,07.36,035 23344,Product 124,18.99,043 14441,Product 125,12.85,143 68691,Product 126,02.46,000 77241,Product 127,19.78,181 41080,Product 128,02.93,025 18586,Product 129,15.12,181 68335,Product 130,20.05,005 36759,Product 131,05.06,031 57422,Product 132,10.59,054 89939,Product 133,05.36,089 68842,Product 134,08.43,073 74762,Product 135,07.46,119 67537,Product 136,04.86,027 89897,Product 137,17.79,083 31848,Product 138,09.22,196 72203,Product 139,17.85,106 77727,Product 140,19.33,113 12602,Product 141,08.49,196 60237,Product 142,18.26,095 73727,Product 143,08.58,139 36852,Product 144,19.72,197 48890,Product 145,12.04,196
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
