+ 1

Please help with this buggy code coach

#include <iostream> using namespace std; int main() { int choice = 0; cin >> choice; /*1 - Latte 2 - Americano 3 - Espresso 4 - Cappuccino 5 - Macchiato */ switch (choice){ case 1: cout << "Latte"; break; case 2: cout << "Americano"; break; case 3: cout << "Espresso"; break; case 4: cout << "Cappucchino"; break; case 5: cout << "Macchiato"; break; } //tu código va aquí return 0; } Why is it wrong? In code coach Cup O’ Joe.

14th Nov 2022, 4:44 PM
Ugulberto SĂĄnchez
Ugulberto SĂĄnchez - avatar
5 Answers
+ 3
I found the solution, thanks for the answers. Sololearn forgot to put a default sentence at the end of the switch condition, and in the solution it doesn’t appear too. So the solution is: #include <iostream> using namespace std; int main() { int choice = 0; cin >> choice; /*1 - Latte 2 - Americano 3 - Espresso 4 - Cappuccino 5 - Macchiato */ //your code goes here switch (choice) { case 1: cout << "Latte" << endl; break; case 2: cout << "Americano" << endl; break; case 3: cout << "Espresso" << endl; break; case 4: cout << "Cappuccino" << endl; break; case 5: cout << "Macchiato" << endl; break; default: cout << "Default" << endl; } return 0; }
14th Nov 2022, 5:10 PM
Ugulberto SĂĄnchez
Ugulberto SĂĄnchez - avatar
+ 2
How is Cappuccino written?
14th Nov 2022, 5:07 PM
Paul
Paul - avatar
+ 1
👍
14th Nov 2022, 5:12 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
0
It fails in try number 4
14th Nov 2022, 4:44 PM
Ugulberto SĂĄnchez
Ugulberto SĂĄnchez - avatar
0
Only write int choice; Don't put the value in choice varible maybe then finally work
14th Nov 2022, 5:08 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar