Create the code as directed in the attached file include usi

Create the code as directed in the attached file #include using namespace std; int main() { // define a character variable called answer // prompt the user to enter their favorite flavor of ice cream // output the following menu: // a : vanilla // b : chocolate // c : strawberry // d : coffee // read the user\'s answer into the answer variable. // create an if statement so that if the user chooses //a - print \"goes great with fudge sauce\" // b - print \"even better with chocolate jimmies\" // c OR d - print \"my favorites too!\" // anything else - print \"Thank you for your vote!\" // create a switch statement using answer as the condition, // using the same outputs system(\"pause\"); return 0; }

Solution

#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char answer;
cout<<\"enter your favourite flavour if ice cream \";
cout<<\"\ a:vanilla \ b:chocolate\ c:strawberry\ d:coffee\";
cin>>answer;
if(answer==\'a\'||answer==\'A\')
cout<<\"\ goes great with fudge sauce\";
else if(answer==\'b\'||answer==\'B\')
cout<<\"\ even better with chocolate jimmies\";
else if(answer==\'c\'||answer==\'C\'||answer==\'d\'||answer==\'D\')
cout<<\"\ my favourite too !\";
else cout<<\"\ Thank you for your vote!\";

switch(toLower(answer))
{
case \'a\':
cout<<\"\ goes great with fudge sauce\";
break;
case \'b\':
cout<<\"\ even better with chocolate jimmies\";
break;
case \'c\':
cout<<\"\ my favourite too !\";
break;
case \'d\':
cout<<\"\ my favourite too!\";
break;
default:
cout<<\"\ Thank you for your vote!\";
}
system(\"pause\");
return 0;
}

 Create the code as directed in the attached file #include using namespace std; int main() { // define a character variable called answer // prompt the user to

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site