i Need help please

its a vending Machine problem
i need a program that displays

1. coke $1.20
2. Diet coke $1.00
3. Swiss Chocolate $1.40
4. Pulpy $1.50
5. iced coffee $1.55
6. Candy $0.95
7. End of transaction

each item name has to be in a array
and item price in another array.

one item can be chosen at a time, the vending machine should continuously display the menu, unless the transaction ends or if the customer has ran out of money
At the end of the transaction it should display the total cost


#include <iostream>
using namespace std;
int main ()
{
void displayHeader ();
void showMenu (string[],double[]);

double itemPrices [6];
itemPrices[0]=1.20;
itemPrices[1]=1.66;
itemPrices[2]=1.40;
itemPrices[3]=1.50;
itemPrices[4]=1.55;
itemPrices[5]=0.95;

string itemNames [6];
itemNames[0]="Coke";
itemNames[1]="Diet Coke";
itemNames[2]="Swiss Chocoalate";
itemNames[3]="Pulpy";
itemNames[4]="Iced Coffee";
itemNames[5]="Candy";






system ("PAUSE");
return 0;
}

i'm stuck please help :(
Use for loops to iterate through the arrays.
1
2
3
for( int i = 0; i < 6; i++ ){
    cout << itemNames[i] << " " << itemPrices[i] << endl;
}
Last edited on
i'm stuck :(
This is better at BEGINNERS, btw you can make your code look prettier with UNIFORM INITIALIZATION, instead of declaring your array and manually assigning each value you can do something like
 
std::string itemNames[6] = {"Coke", "Diet Coke", "Swiss Chocolate", "Pulpy", "Iced Coffee", "Candy"};
Last edited on
Topic archived. No new replies allowed.