+ 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.
5 Antworten
+ 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;
}
+ 2
How is Cappuccino written?
+ 1
👍
0
It fails in try number 4
0
Only write int choice;
Don't put the value in choice varible maybe then finally work