can someone tell me whats wrong with it or what i should do?
#include <iostream>
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
using namespace std;
List storage[50];
int e = 50;
int intro(void)
{
int userChoice;
cout << "Enter 1 to checkout or 0 to end checkout.";
cin >> userChoice;
return userChoice;
};
void display()
{
for (int element = 0; element < e; element++)
{
cout << storage[element].getPLU() << storage[element].getname()
<< storage[element].gettype() << storage[element].getprice << storage[element].getlevel() << endl;
}
}
void userCheck(void)
{
int PLU = 0;
int userIn;
float units;
float sum = 0;
do
{
PLU = 0;
cout << "Please enter PLU number or 0 to leave.";
cin >> userIn;
if (userIn == 0)
{
break;
}
for (int element = 0; element < e; element++)
{
if (storage[element].getPLU() == userIn)
{
PLU = element;
break;
}
}
if (storage[PLU].gettype() == 1)
{
cout << "Pounds: ";
}
else
{
cout << "Units: ";
}
cin >> units;
sum = sum + units + storage[PLU].getprice();
storage[PLU].reevaluateLevel(units);
} while (userIn!=0);
cout << "Your total amount of money is: $" << sum << endl;
if (sum > 50)
{
sum = (0.95*sum);
cout << "Congratulations! You've received a 5% discount. Your total is: $"
<< sum << endl;
}
}
class List
{
private:
int PLUcode;
string itemName;
int itemType;
double itemPrice;
double itemLevel;
public:
List();
List(int, string, int, double, double);
int getPLU();
string getname();
int gettype();
double getprice();
double getlevel();
double reevaluateLevel(double);
};
List::List()
{
PLUcode = 0;
itemName = "no name";
itemType = 0;
itemPrice = 0;
itemLevel = 0;
}
List::List(int PLUcod, string itemNam, int itemTyp, double itemPri, double itemLev)
{
PLUcode = PLUcod;
itemName = itemNam;
itemType = itemTyp;
itemPrice = itemPri;
itemLevel = itemLev;
}
int List::getPLU()
{
return PLUcode;
}
string List::getname()
{
return itemName;
}
int List::gettype()
{
return itemType;
}
double List::getprice()
{
return itemPrice;
}
double List::getlevel()
{
return itemLevel;
}
double List::reevaluateLevel(double units)
{
if (units > itemLevel)
{
cout << "Item is not available." << endl;
}
else
{
itemLevel -= units;
}
return itemLevel;
}
int main()
{
int PLUcode;
string itemName;
int itemType;
double itemPrice;
double itemLevel;
string inputFile = "ass3items.txt";
ifstream filename;
int temp;
if (filename.is_open())
{
while (!filename.eof())
{
filename >> PLUcode >> itemName >> itemType >> itemPrice >> itemLevel;
List temp = List(PLUcode, itemName, itemType, itemPrice, itemLevel);
storage[e] = temp;
e++;
}
}
int userChoice;
do
{
cout << "Welcome to the Checkout! " << endl;
userChoice = intro();
if (userChoice == 1)
{
userCheck();
}
else
{
display();
}
} while (userChoice != 0);
return 0;
}