0

Can anyone help me. I have a c++ project to do. The program must simulate a vending machine. I will post what i have so far. a data file must be hardcoded into it which provides the different drinks.

```
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int SIZE=54;
int cans;
typedef string vendingArray[SIZE];
int main()
{
int cans;
int choice;
int balance=0;
int dollar=0;
int half=0;
int nickle=0;
int dime=0;
int quart=0;
int cent=nickle+dime+quart+half;
vendingArray sodaMachine;
cout <<"=======================================""\n";
cout <<"Welcome To The Drink Vender""\n";
cout <<"This program simulates a vending machine""\n";
ifstream infile;
infile.open("machine.txt");
if(!infile)
{
cout <<"Error: Data Cannot Be Opened";
exit( EXIT_FAILURE );
}
else
{
infile >> cans;
for(int i=0; i < cans; i++)
{
infile >> sodaMachine[i];
cout << sodaMachine[i] << "\n";
}
}
infile.clear();
infile.close();
cout <<"The current balance is\t" <<dollar << " dollars and "<< cent <<" cents "<<endl;
cout <<"Please choose from one of these options"<<endl;
cout <<"\n";
cout << "\n" <<"Enter a number to choose an option:\t";
cin >> choice;
if (choice==5)
{
balance +=5;
}
if (choice==10)
{
balance +=10;
}
if (choice==25)
{
balance +=25;
}
if (choice==50)
{
balance +=50;
}
if (choice==100)
{
balance +=100;
}
if (choice==45)
{
balance -=45;
}
if (choice==50)
{
balance -=50;
}
if (choice==55)
{
balance -=55;
}
if (choice==60)
{
balance -=60;
}
if (choice==70)
{
balance -=70;
}
if (choice==85)
{
balance -=85;
}
return(0);
}
```