so this is a checkout program. the problem i have is that the program doesnt work with the other PLU numbers only the 1st one. any thoughts on how to fix this?
4011 BANANAS 1 0.49 123.2
4383 MINNEOLAS 1 0.79 187.3
3144 TANGERINES 1 1.19 135.5
4028 STRAWBERRIES_PINT 0 0.99 104
4252 STRAWBERRIES_HALF_CASE 0 3.99 53
4249 STRAWBERRIES_FULL_CASE 0 7.49 67
#include <iostream>
#include <string>
#include <fstream>
usingnamespace std;
struct storePro
{
int PLUcode;
string itemName;
int itemType;
double itemPrice;
double itemLevel;
};
int main()
{
ifstream filename("checkoutList.txt");
storePro array[6];
int o;
{
for (int o = 0; o < 6; o++)
{
filename >> array[o].PLUcode >> array[o].itemName >> array[o].itemType >> array[o].itemPrice >> array[o].itemLevel;
}
}
cout << " ";
cout << " ";
int userChoice;
cout << "Enter 1 to checkout or 0 to end checkout.";
cin >> userChoice;
do
{
//cout << "Welcome to the Checkout! " << endl;
if (userChoice == 1)
{
int count = 0;
int PLU = 0;
int userIn;
float units;
float sum = 0;
//cout << "Please enter PLU number or 0 to leave.";
//cin >> userIn;
do
{
PLU = 0;
cout << "Please enter PLU number or 0 to leave.";
cin >> userIn;
if (userIn == 0)
{
break;
}
for (int element = 0; element < 6; element++)
{
if (array[element].PLUcode == userIn)
{
PLU = element;
break;
}
What do you mean by "doesn't work"? Does it crash? Does it send a bomb with your name on it to the FBI? Does it email your grandmother a virus? You need to be specific.
PLU = -1;
cout << "Please enter PLU number or 0 to leave.";
cin >> userIn;
if (userIn == 0)
{
break;
}
for (int o = 0; o < 6; o++)
{
if (array[o].PLUcode == userIn)
{
PLU = o;
//invalid = o;
break;
}
}
if (PLU == -1)
{
cout << "PCU code was not found." << endl;
PLU = 0;
break;
}
bool found = false;
PLU = 0;
//PLU = -1;
cout << "Please enter PLU number or 0 to leave.";
cin >> userIn;
if (userIn == 0)
{
break;
}
for (int o = 0; o < 6; o++)
{
if (array[o].PLUcode == userIn)
{
PLU = o;
//invalid = o;
break;
}
}
//if (PLU == -1)
if(!found)
{
cout << "PCU code was not found." << endl;
break;
}
oh ok ill try it, different question, almost everytime i make a change and build it i get an error that says cannot open .......... for writing LINK, do you know how to fix this?