No No 3. You have a group of friends coming to visit for your high school reunio
ID: 3723024 • Letter: N
Question
No No 3. You have a group of friends coming to visit for your high school reunion, and you want to take them out to eat at a local restaruant. You aren't sure if any of them have dietary restrictions, but your restaruant choices are as follows: Restaurant Name | Vegetarian? | Vegan? | Gluten-Free Joe's Gourmet Burgers No Main Street Pizza Company Yes No Yes Corner Cafe Yes Yes Mama's Fine Italian Yes No The Chef's Kitchen Yes Yes Yes Write a program that asks whether any members of your party are vegetarian, vegan, or require gluten-free food. It should then display only the restaurants to which you may take the group. Yes No ~/workspace/HW/ $ python number03.py Is anyone in your party a vegetarian? yes Is anyone in your party a vegan? no Does anyone in your party require gluten-free food? yes Here are your restaurant choices: Main Street Pizza Company Corner Cafe The Chef's KitchenExplanation / Answer
#include <iostream>
#include <string>
using namespace std;
int main() {
// declaring varaibles
int vegetarian[5] = {0, 1, 1, 1, 1};
int vegan[5] = {0, 0, 1, 0, 1};
int gfree[5] = {0, 1, 1, 0, 1};
string rname[5] = {"Joe's Gourmet Burgers", "Main Street Pizza Company","Corner Cafe", "Mama's Fine Italian", "The Chef's Kitchen"};
// taking user input for 3 choices
string one, two, three;
cout << "Is anyone in your party a vegetarian? ";
cin >> one;
cout << "Is anyone in your party a vegan? ";
cin >> two;
cout << "Does anyone in your party require gluten-free food? ";
cin >> three;
// looping through each restaurant to see if it can be considered
// when the answer is yes, we have to see if the restaurant has that available or not. If not available then we have to skip (continue) it.
cout << endl << "Here are your restaurant choices: "<< endl;
for(int i=0; i<5; i++)
{
if (one.compare("yes") == 0 && vegetarian[i] == 0)
continue;
if (two.compare("yes") == 0 && vegan[i] == 0)
continue;
if (three.compare("yes") == 0 && gfree[i] == 0)
continue;
// if it came here, it passed all the above cases
cout << rname[i] << endl;
}
}
/*
****** Sample output 1
Is anyone in your party a vegetarian? yes
Is anyone in your party a vegan? no
Does anyone in your party require gluten-free food? yes
Here are your restaurant choices:
Main Street Pizza Company
Corner Cafe
The Chef's Kitchen
****** Sample output 2
Is anyone in your party a vegetarian? yes
Is anyone in your party a vegan? no
Does anyone in your party require gluten-free food? no
Here are your restaurant choices:
Main Street Pizza Company
Corner Cafe
Mama's Fine Italian
The Chef's Kitchen
*/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.