+ 1
Ballpark Order-Challenge
This code works fine for the first test. But none of the others. I have no idea what could be wrong. #include <iostream> using namespace std; int main() { string answer[4]; string ans0; float sum=0; int x=0; do { cin >>ans0; answer[x]=ans0; if(ans0=="Nachos"||ans0=="Pizza") { sum+=6.00; } if(ans0=="Cheeseburger") { sum+=10.00; } if(ans0=="Water") { sum+=4.00; } else { sum+=5.00; } x++; }while(x<4); sum*=1.07; cout << sum; return 0; }
4 Answers
+ 3
You have to use if-else block, last else part tied with if(ans0=="Water") Only...
like:
if (...)
else if(..)
else if(...)
else
...
+ 4
Also, you're missing "Coke" in your solution.
+ 2
Simba I decided to skip adding an else if for âCokeâ specifically. Only reason being because a friend ordering something thatâs not on the menu would end up as âCokeâ anyways.
+ 1
Jayakrishnađźđł I always forget about those âelse ifâsâ đ€ŠđŒââïž