Please write [cod
e] and [/co
de] around your code so the forum will preserve indentation and syntax highlight it for us when we read it.
The problem, I think, is that your variables for storing the user's choices are characters; this means when you compare the integral 1 to it, you are using the character with ASCII value 1, which is the SOH (start of heading) control character. Not what I think you meant!
The character '1' is represented by ASCII value 49, so you could compare to that, though I would recommend just using the literal
'1'
- that's a 1 in single quotes - to mean the character 1.
Other notes:
Instead of creating temporary float variables then assigning them to the variable you use to store the choice:
1 2 3
|
// What you are doing:
float DrinkPrice3 = 6.00;
DrinkChoice = DrinkPrice3;
|
Just assign to it directly:
1 2
|
// More succinct:
DrinkChoice = 6.00;
|
Your function is incredibly simple and so in normal cases I'd recommend just removing it, but I can see it is probably for learning reasons. You could at least simplify it similarly to the above:
1 2 3
|
float addition(float a, float b) {
return a + b;
}
|