Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with this program I have no idea how to do it. I tried for hours. It

ID: 3876708 • Letter: I

Question

I need help with this program I have no idea how to do it. I tried for hours. It needs to be in c++ and try to make it simple yet still do all the requirements please! The last one I did did not read the file the correct way?

The txt file is:

Zip Drive

89

Warehouse C

75.89

Keyboard

133

Warehouse C

25.95

Blu Ray

54

Warehouse J

34.87

Iphone

110

Warehouse M

209.93

Ipod

174

Warehouse M

180.99

DVD Player

85

Warehouse J

124.91

Heat Sink

157

Warehouse C

138.45

Ext Drive

245

Warehouse C

152.87

Speakers

187

Warehouse J

163.55

Camera

147

Warehouse J

138.97

SD Card

100

Warehouse C

18.87

Router

148

Warehouse C

115.28

Printer

125

Warehouse M

145.87

Bluetuth Speakers

102

Warehouse J

19.99

Microsoft Mouse

202

Warehouse J

49.99

USB Hub

7

Warehouse M

29.99

Mousepad

119

Warehouse C

9.99

HDMI cable

23

Warehouse C

32.50

Tablet

56

Warehouse M

199.99

Create a program that will read data from a file called prog1.txt. The data will consist of the product item name, quantity, location and price for products in an inventory. You do not know how many data items there will be in the file and should read the file until no more data is found. Some strings will contain a space (use getline). All of the output for the program will go to the screen. Have the main call a function to input the data from the file progl.txt and store the data in four parallel arrays, item, qty, location and price. The max number of elements should be set to 30 utilize a globally declared named constant. However, the input function will keeps track of the number of products actually read from the file and return that count to main0. It is possible that the data file contains more than 30 items in it, handle that in your function knowing that you only have room for 30 in your arrays. The main) should: . Declare all arrays and variables needed 2. Call the ReadData function to read the data and populate the arrays a. b. c. d. Pass the arguments needed Open the file prog1.txt inside this function. Use a while loop to read data into the arrays until EOF is reached and you have room in the arrays. close the file 3. Call the BSort function to sort all four arrays from highest to lowest by quantity. (WORRY ABOUT THIS FUNCTION LAST, IN THE MEANTIME, USE A STUB) a. Use the bubble sort to sort all four arrays simultaneously using the qty array as the key 4. Call the PrintArrays function that prints the four arrays in tabular form with column headers Print the arrays in tubular form using formatting via the setw function a. 5. Call the Restock function to print each product that is under stock. A product is under stock if it has fewer than 100 items in stock. Display the product item name and quantity in tahular form. Call the HiPrice function to return the subscrint of the highest price product in stock via the return statement. Call the AverWarehouse function to return the average price for each of the three warehouses (see data). (Hint: You will 6. 7. need three sets of counters and accumulators. Lastly, the function will return all three averages via reference parameters). 8. Add code in your main to display the item name, location and price of the highest price product in stock. (Output: The highest priced item is located in warehouse with a price of $ 9. Add code in your main to display the average prices for all three warehouses.

Explanation / Answer

#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int linearSearch (string [], int, string);
int main ()

{
cerr << "the available commands are ";
cerr << "/rawprices, this is the first command needed when making an invoice.";
cerr << " Here the product and price are entered ";

cerr << "/items is the seccond command used when making an invoice. ";
cerr << "The item name and then quantity are entered ";
  
cerr << "/invoice, once all data has been entered the user enters this ";
cerr << " command to view the outputed invoice ";
  
cerr << "/ this command exits the program ";
  
cerr << "please input one of the available commands: ";
  
string item[100];
string products[200];
double prices[200];
string str;
int numPurchase = 0;
int numProd = 0;
int quantity[100];
double total;
cin>> str;
  

  

if( str == "/rawprices")
{
cerr << " enter the items name and then price ";
cerr << "for example type dog 1 and then press enter ";
cerr << "enter items and their prices one at a time, you can enter as many items ";
cerr << "as you like ";
cin >> str;
  
while( str[0] !='/')
{
products[numProd] = str;
cin>> prices[numProd];
numProd++;
cin >> str;  

}
}

if( str == "/items")
{
cerr << " now enter the products name and how many items ";
cerr << "for example dog 50 and then press enter ";
cin >> str;
  
while( str[0] !='/')
{

item[numPurchase] = str;
cin>> quantity[numPurchase];
numPurchase++;
cin >> str;  
}
}
  
if (str == "/invoice")
{
cout << "phantom company invoice ";
cout << "PRODUCT ID" << setw(13) << "QUANTITY" << setw(11) << "PRICE ($)" << setw(13) << "COST($)" << setw(11) <<" ";

int locations;
double price;
double cost;

for (int i=0; i<numPurchase; i++)

{
  
cout << item[i] <<setw(17) << fixed << setprecision(0) << quantity[i];



  
  
int location = linearSearch (products, numProd, item[i]);
  
price = prices[location];
  
cost = price * quantity[i];
total = cost + cost;
  
  
cout << setw(10) << fixed << setprecision(0)<< price;
cout << setw(13) << fixed << cost;
  
  
  
}  
}

cout << setw(32) << " TOTAL COST = $" << total;


system ("pause");
return 0;
}
int linearSearch(string list[], int size, string key)
{
int i;
for (i = 0; i < size; i++)
{if (list[i] == key)
return i;
}
return -1;
}