#include <iostream>
using namespace std;
int main()
{
int answer = -1; // out of case value.
while (cin >> answer) {
switch (answer) {
case 1:
cout << "Expresso" << endl ;
break;
case 2:
cout << "American" << endl ;
break;
case 3:
cout << "Cappucino" << endl ;
break;
case 4:
cout << "Latte" << endl ;
break;
default:
return false; // quit the loop
break;
}
}
}
// 3 resources files needed : IOstream / Vector / string
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
int answer = -1; // out of case value.
vector<string> product = {"Expresso","Americano","Capucino","Latte"};
while (cin >> answer) {
if ( answer > 4 || answer < 1 ) { return false; }
cout << product.at(answer-1) << endl; // to keep the good array index for 'product' : "answer -1"
}
}
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.