Program must match the photo** This lab is to to add another option for the user to print warnings of any inventory running low. More specifically: - Add another option to the menu, called W for Warning - Look at all items, in all locations. If an item has less than 10 left, print out on one line the item name, location, and quantity. A photo of the example run is attached Contents of Inventory.txt Red delicious apples 1.00 25 6 8 10 Assorted bouquets 4.00 50 10 10 0 Camembert cheese 2.00 25 10 12 4
**
This lab is to to add another option for the user to print warnings of any inventory running low. More specifically:
- Add another option to the menu, called W for Warning
- Look at all items, in all locations. If an item has less than 10 left, print out on one line the item name,
location, and quantity.
A photo of the example run is attached
Contents of Inventory.txt
Red delicious apples
1.00 25 6 8 10
Assorted bouquets
4.00 50 10 10 0
Camembert cheese
2.00 25 10 12 4
END
Program that is being added to:
#include <iostream>
#include <fstream>
#include <
using namespace std;
struct Record {
string name;
double cost;
int markup;
int count[3];
};
const string places[3] = {"counter", "shelf", "warehouse"};
bool read_file(vector <Record> &v);
void placement (vector <Record> &v);
int main()
{
vector <Record> invent;
char choice;
if (read_file(invent) == false) {
return 1;
}
cout << "You have " << invent.size() << endl;
while (true)
{
cout << "(P)lacement e(X)it: ";
cin >> choice;
switch(choice) {
case 'P':
case 'p':
placement(invent);
break;
case 'X':
case 'x':
return(0);
break;
default:
cout << choice << " is not a chice\n";
}
}
return 0;
}
void placement (vector <Record> &v)
{
int which = -1;
string input;
cout << "Which? ";
cin >> input;
for (int i = 0; i < 3; i++) {
if (input.substr(0,3) == places[i].substr(0,3)) which = i;
}
if (which == -1) {
cout << "No match\n";
return;
}
cout.setf(ios::left);
cout.unsetf (ios::right);
cout.width(30);
cout << "Item";
cout.setf(ios::right);
cout.width(6);
cout << places[which] << "\n";
int j;
for (j = 0; j < v.size(); j++) {
cout.setf(ios::left);
cout.unsetf (ios::right);
cout.width(30);
cout << v[j].name;
cout.setf(ios::right);
cout.width(6);
cout << v[j].count[which] << endl;
}
}
bool read_file(vector <Record> &v)
{
Record r;
ifstream infile;
infile.open("inventory.txt");
if (infile.fail()) {
cout << "can't open file\n";
return (false);
}
while (true) {
getline (infile, r.name);
cout << "Read " << r.name << endl;
if (r.name == "END") {
infile.close();
return true;
}
else {
infile >> r.cost >> r.markup;
for (int i = 0; i < 3; i++) infile >> r.count[i];
infile.get();
v.push_back(r);
}
}
return true;
}
![Read Red delicious apples
Read Assorted bouquets
Read Camembert cheese
Read END
You have 3
(P)lacement (W) arning e (X) it: w
Warning: Red delicious apples counter 6
Warning: Red delicious apples shelf 8
Warning: Assorted bouquets warehouse 0
Warning: Camembert cheese warehouse 4
(P) lacement (W) arning e (X)it:](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5bd3697d-7244-4dc8-845a-c06954fa71b0%2F646e1494-ecff-487a-a204-7a7cf110ff68%2Fnpy3wp5_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Systems Architecture](https://www.bartleby.com/isbn_cover_images/9781305080195/9781305080195_smallCoverImage.gif)
![Operations Research : Applications and Algorithms](https://www.bartleby.com/isbn_cover_images/9780534380588/9780534380588_smallCoverImage.gif)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)
![Systems Architecture](https://www.bartleby.com/isbn_cover_images/9781305080195/9781305080195_smallCoverImage.gif)
![Operations Research : Applications and Algorithms](https://www.bartleby.com/isbn_cover_images/9780534380588/9780534380588_smallCoverImage.gif)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)