Question
I am uploading a picture of the .csv file and my code please try to fix the code,seekg needs to be used.Please use c++ and
I am uploading a picture of the .csv file and my code please try to fix the code,seekg needs to be used.Please use c++ and there should be a .txt file for the invoice ( my code does it try running it first) thank you, your help is really appreciated. https://filebin.net/gyhg2135a0gxoaif this it the link for the .csv file that needs to be used.
#include
using namespace std;
string Customername; //declaring variables string streetAddress; string zipCode; int totalCost = 0;
void customerInformation(); //function prototype
float cart[145][5]; int index = 0; int Loadfunction(float array1[][4], int value) {
for (int j = 0; j
void customerInformation(){ // customer information function fstream Output("customerinfo.txt", ios::out); cout > Customername; Output
cout > streetAddress; Output
cout > zipCode; Output
}
void Load(float array2[][5]) { fstream Outfile("Invoice.txt", ios::out); //print to invoice.txt
Outfile
double totalcost = 0; for (int i = 0; i
} Outfile
void addToCart(float Productname, int itemnumber, int qty, float productcost,float totalCost) { //add data to shopping cart
cart[index][0] = itemnumber; cart[index][1] = Productname; cart[index][2] = qty;cart[index][3] = productcost;cart[index][4] = (qty*productcost);cart[index][5] = totalCost + cart[145][5];
index++;
} int main() { // main function
float a[145][4];
fstream infile("ProductData.csv", ios::in); //file input
infile.seekg(26L, ios::beg);
for (int rowcount = 0; rowcount > a[rowcount][0]; infile.seekg(8L, ios::cur); infile >> a[rowcount][1]; infile.seekg(1L, ios::cur); infile >> a[rowcount][2]; infile.seekg(1L, ios::cur); infile >> a[rowcount][3]; infile.seekg(1L, ios::cur); }
int useritemnumber;
int count = 0; //counter set to 0 do { cout > useritemnumber; Loadfunction(a, useritemnumber); int index = Loadfunction(a, useritemnumber);
if (Loadfunction(a, useritemnumber) == -1) { //when item is not found cout
int QTY; cout > QTY;
while (QTY > a[index][3]) { //while quantity is greater than stock cout > QTY;
}a[index][3] = a[index][3] - QTY; addToCart(Productname, useritemnumber, QTY, ProductCost, totalCost);
}
count++; } while (!useritemnumber == 0); Load(cart); if (infile.fail()) { cout
}
customerInformation();
system("pause");
return 0; }
Please use c++, I am uploading my code and it needs to be adjusted according to the new instructions. your help is really appreciated ( please try to fix the code) Feature Updates Dynamic Memory - You no longer know how many items are in the inventory file. You now have to be able to accept any number of items. When the program is graded they inventory list will be in the same format but the number of items in the list will be unknown until after your program is running 1. The first item in the inventory file is the number of items in the list. Read in the first line and create a dynamic memory based upon this number a. b. Instead of using arrays you must use structs to store the data. Points will be deducted for not using a struct. You need to update your search function to work with the new dynamic data and struct. c. 2. You need to create a shopping cart for the user. Use a data structure of your choice to store what the user has selected to purchase. Remember the user can add as many items to their cart as there are in the inventory list a. You need to be able to search through the shopping cart. b. If a person enters in a duplicate item that is already in the cart then it should increase the qty in the cart. You need to make sure that you have enough inventory to support the change Do not worry right now about the user removing anything in the cart. Add in a function that prints the customers cart out. Anytime a user types "cart when entering items your program should print the user current contents of the cart. You must write this as a function or points will be deducted c. d. 3. Prepare for the next customer by updating the inventory file. After the customer is done shopping you need to update the inventory file so that it matches the new qty's of items left in inventory. Do not just overwrite the file. You must use seekp to update the qty's first loaded the a. The file should be the same name and same format as when you Remember to delete any allocated memory at the correct times of your program! Failure to do this will cause a reduction in your grade ProductData.csv Notepad File Edit Format View Help 45 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 Please use c++, I am uploading my code and it needs to be adjusted according to the new instructions. your help is really appreciated ( please try to fix the code) Feature Updates Dynamic Memory - You no longer know how many items are in the inventory file. You now have to be able to accept any number of items. When the program is graded they inventory list will be in the same format but the number of items in the list will be unknown until after your program is running 1. The first item in the inventory file is the number of items in the list. Read in the first line and create a dynamic memory based upon this number a. b. Instead of using arrays you must use structs to store the data. Points will be deducted for not using a struct. You need to update your search function to work with the new dynamic data and struct. c. 2. You need to create a shopping cart for the user. Use a data structure of your choice to store what the user has selected to purchase. Remember the user can add as many items to their cart as there are in the inventory list a. You need to be able to search through the shopping cart. b. If a person enters in a duplicate item that is already in the cart then it should increase the qty in the cart. You need to make sure that you have enough inventory to support the change Do not worry right now about the user removing anything in the cart. Add in a function that prints the customers cart out. Anytime a user types "cart when entering items your program should print the user current contents of the cart. You must write this as a function or points will be deducted c. d. 3. Prepare for the next customer by updating the inventory file. After the customer is done shopping you need to update the inventory file so that it matches the new qty's of items left in inventory. Do not just overwrite the file. You must use seekp to update the qty's first loaded the a. The file should be the same name and same format as when you Remember to delete any allocated memory at the correct times of your program! Failure to do this will cause a reduction in your grade ProductData.csv Notepad File Edit Format View Help 45 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
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