I am having trouble with enumeration and array in my soda vending machine code. This program is composed of numerous functions, including inserting money, selecting soda, calculating change (if any), a loop to continue or not, then my file IO includes printing a receipt, and in this section with the file IO, I added array with soda count. SO, the problem is I declared enumeration variables, but I do not know how to implement it in the code, I just declared it. Also, with the File IO and array (it's in the same section, near bottom) I intended the file output to print out a receipt with the soda count and the amount deposited and change, but it does not print it out, it prints out something else).
So can anyone please help me with the enumeration, and the file IO and array?
You have an array soda sodas[3]; - but nowhere do you set any of the values in this array - so the second value on a line in your receipt which is sodas[count] is just rubbish.
OOPS I need to edit this:
You are not returning the value of the soda from the displayMenu function - so the
value of sodas[count] is rubbish.
You do not return the change value from your giveChange function - so the line double changeDue=giveChange(amountDeposited);gives changeDue an undefined value (this means that the third value on a line on the receipt is rubbish - if this value shows as NAN that means Not A Number ).
Another EDIT:
By the way - if you expect the actual words COKE, SPRITE, DRPEPPER to appear in your receipt file -
they won't - you will get a value of 0, 1 or 2 - if you want the words you will have to add some more
code.
ok i just fixed enum but, i still am having trouble with the array.
guestgulkan what do you suggest, i already know that it gives me back and undefined value
this is what came out on the text file 244697121.#QNAN, how do i fix it, below is my updated code with enum