I’m building a (very) small grocery store as a class assignment. I’m trying to figure out how to break out of this loop I built if the 7 key is pressed. When I run it (github) it wont break the loop if 7 is entered. Any idea why? Thanks in advanced.
(fyi variables are all created, cinreader is present, The loop runs, I just can’t break out of the loop)
userInput = reader.ReadIntegerRange(1, 7)
for userInput != 7 {
if userInput == 1 {
subtotal += bananas
} else if userInput == 2 {
subtotal += chicken
} else if userInput == 3 {
subtotal += eggs
} else if userInput == 4 {
subtotal += proteinBars
} else if userInput == 5 {
subtotal += oatmeal
} else if userInput == 6 {
subtotal += blueBerries
} else{
break
}