Menu
support@nursinghomework.org
+1 714-215-3097

(Solved) : Uploading Picture Csv File Code Please Try Fix Code Seekg Needs Usedplease Use C Txt File Q35620221

I am uploading a picture of the .csv file and my code please tryto fix the code,seekg needs to be used.Please use c++ and thereshould be a .txt file for the invoice ( my code does it try runningit first) thank you, your help is really appreciated.https://filebin.net/gyhg2135a0gxoaif this it the link for the .csvfile that needs to be used.Please use c++, I am uploading my code and it needs to be adjusted according to the new instructions. your help is really appProductData.csv Notepad File Edit Format View Help 45 Item Number, Name, Cost,Qty 12735, Product 001,02.09,121 69703, Product

#include <iostream> //preprocessor statement
#include <fstream>
#include <string>

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 < 145; j++) { //for loopreturn to j if equal to value
      if (array1[j][0] == value) {
         return j;
      }
   }       return -1; // if notreturn to -1
}

void customerInformation(){
   // customer information function
   fstream Output(“customerinfo.txt”, ios::out);
   cout << “Please Enter yourname:          “<< endl; //customer name
   cin >> Customername;
   Output << Customername << endl;

   cout << “Please enter your streetaddress:         ” <<endl; // customer address
   cin >> streetAddress;
   Output << streetAddress << endl;

   cout << “Please enter yourzipcode:            ” << endl; // customer zipcode
   cin >> zipCode;
   Output << zipCode << endl;

}

void Load(float array2[][5]) {
   fstream Outfile(“Invoice.txt”, ios::out); //print toinvoice.txt

   Outfile <<“**********************************INVOICE*********************************”<< endl;

   Outfile << “Itemnumbert” <<“Productnamet” << “Priceperquantityt” <<“totalCostt” << endl;

double totalcost = 0;

   for (int i = 0; i < index; i++) {
    
      Outfile << array2[i][0]<< “tt” << array2[i][1] << “t” <<array2[i][2] << “t” << array2[i][3] << “t”<< array2[i][4] << “t” << endl;
      totalcost = totalcost +array2[i][4];

   }
   Outfile << “ttttttt total: ” <<totalcost << endl; //output the total cost in invoice.txtfile

}

void addToCart(float Productname, int itemnumber, int qty, floatproductcost,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); //fileinput

   infile.seekg(26L, ios::beg);

   for (int rowcount = 0; rowcount < 145;rowcount++) {
      infile >> 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 << “please enter the itemnumbers: ” << endl;   //enter the item number
      cin >> useritemnumber;
      Loadfunction(a,useritemnumber);
      int index = Loadfunction(a,useritemnumber);

      if (Loadfunction(a,useritemnumber) == -1) {   //when item is not found
         cout <<“Item was not found” << endl;
      }
      else{                    //
         float Productname= a[index][1];
         float ProductCost= a[index][2];
       
         cout <<“Item name: ” << Productname << endl; //item name inconsole
         cout <<“Cost of Item: ” << ProductCost << endl; // cost of thein console

         int QTY;
         cout <<“Please enter the quantity: ” << endl;
         cin >>QTY;

         while (QTY >a[index][3]) { //while quantity is greater than stock
           cout << “Desired quantity is not in stock” <<endl;
           cout << “Quantity in stock: ” << a[index][3] <<endl; //quantity in stock
           cout << “Please enter the quantity again: ” <<endl;
           cin >> QTY;

         }a[index][3] =a[index][3] – QTY;
        addToCart(Productname, useritemnumber, QTY, ProductCost,totalCost);

      }

      count++;
   } while (!useritemnumber == 0);
   Load(cart);
   if (infile.fail()) {
      cout << “file cannot open”<< endl;
      return 0;

   }

   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 Show transcribed image text 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

Leave a Reply

Your email address will not be published. Required fields are marked *