:!: I'm very new to programing, been trying to write this coke machine program. Can anybody help me.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int getcoins ()
{
int total = 0, number;
cout << "put in coins: ";
while (total < 65)
{
cin >> number;
if (number == 100) ;! (number == 25) ;! (number && 10) ;! (number & 5)
total; += number;
if (total < 65) cout << "add more coins:" << endl;
}
return total;
}
//function to see if selection is available bool checkselection (char * machine, char select)
{
bool isavailable = false;
for (int i = 0; i < 9; i++)
if (*(machine +i) == select) isavailable = true; //check if c s or d is available *(machine + i) = ' '; //change selected item to space to initiate that it is gone return isAvailable;
}
int main()
{
do I use char?
char "machine = ??ne char [10]
*(machine + 0) = 'c';
*(machine + 1) = 'c';
*(machine + 2) = 'c';
*(machine + 3) = 's';
*(machine + 4) = 's';
*(machine + 5) = 's';
*(machine + 6) = 'd';
*(machine + 7) = 'd';
*(machine + 8) = 'd';
cout << "\t\t **********************" << endl;
cout << "\t\t\tTony's HIP POP SODA MACHINE" << endl;
cout << "\t\t **********************" << endl << endl
cout << "make selection c for Coke, s for Sprite, d for Dr. Pepper:";
cin >> select;
if ('checkselection (machine, select);
cout << "your chnage is " << change << "cents:" << endl;
cout << getcoins() << endl;
return 0;
}