In: Computer Science
Restaurant Selector IN JAVA
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 restaurant. You aren’t sure if any of them have dietary restrictions, but your restaurant choices are as follows:
Joe’s Gourmet Burgers –
Vegetarian: No,
Vegan: No,
Gluten-Free: No
Main Street Pizza Company –
Vegetarian: Yes,
Vegan: No,
Gluten-Free: Yes
Corner Café –
Vegetarian: Yes,
Vegan: Yes,
Gluten-Free: Yes
Mama’s Fine Italian –
Vegetarian: Yes,
Vegan: No,
Gluten-Free: No
The Chef’s Kitchen –
Vegetarian: Yes,
Vegan: Yes,
Gluten-Free: Yes
Write a program that asks whether any members of your party are vegetarian, vegan, or gluten-free, and then display only the restaurants that you may take the group to. Here is an example of the program’s output:
Is anyone in your party a vegetarian? yes[Enter] Is anyone in your party a vegan? no[Enter] Is anyone in your party gluten-free? yes[Enter] Here are your restaurant choices: Main Street Pizza Company Corner Cafe The Chef’s Kitchen
Here is another example of the program’s output:
Is anyone in your party a vegetarian? yes [Enter] Is anyone in your party a vegan? yes [Enter] Is anyone in your party gluten-free? yes [Enter] Here are your restaurant choices: Corner Cafe The Chef’s Kitchen
SOLUTION-
I have solve the problem in Java code with screenshot for easy
understanding :)
CODE-
//java code
import java.util.Scanner;
//class restaurent
public class Restaurents {
//main method
public static void main(String[] args) {
String choice[]={"","",""};
Scanner sc=new Scanner(System.in);
System.out.println("Is anyone at your party vegetarian:");
choice[0]=sc.nextLine();
System.out.println("Is anyone at your party a vegan:");
choice[1]=sc.nextLine();
System.out.println("Is anyone at your party gluten free:");
choice[2]=sc.nextLine();
System.out.println("Here are your restaurent choices:");
if(choice[0].equalsIgnoreCase("yes") &&
choice[1].equalsIgnoreCase("yes") &&
choice[2].equalsIgnoreCase("yes"))
{
System.out.println("Corner's cafe");
System.out.println("Chef's kitchen");
}
else if(choice[0].equalsIgnoreCase("yes") &&
choice[1].equalsIgnoreCase("yes") &&
choice[2].equalsIgnoreCase("no"))
{
System.out.println("Corner's cafe");
System.out.println("Chef's kitchen");
}
else if(choice[0].equalsIgnoreCase("yes") &&
choice[1].equalsIgnoreCase("no") &&
choice[2].equalsIgnoreCase("yes"))
{
System.out.println("Main Street pizza company");
System.out.println("Corner's cafe");
System.out.println("Chef's kitchen");
}
else if(choice[0].equalsIgnoreCase("no") &&
choice[1].equalsIgnoreCase("yes") &&
choice[2].equalsIgnoreCase("yes"))
{
System.out.println("Corner's cafe");
System.out.println("Chef's kitchen");
}
else if(choice[0].equalsIgnoreCase("yes") &&
choice[1].equalsIgnoreCase("no") &&
choice[2].equalsIgnoreCase("no"))
{
System.out.println("Main Street pizza company");
System.out.println("Corner's cafe");
System.out.println("Mama's fine Italian");
System.out.println("Chef's kitchen");
}
else if(choice[0].equalsIgnoreCase("no") &&
choice[1].equalsIgnoreCase("no") &&
choice[2].equalsIgnoreCase("yes"))
{
System.out.println("Main Street pizza company");
System.out.println("Corner's cafe");
System.out.println("Chef's kitchen");
}
else if(choice[0].equalsIgnoreCase("no") &&
choice[1].equalsIgnoreCase("yes") &&
choice[2].equalsIgnoreCase("no"))
{
System.out.println("Corner's cafe");
System.out.println("Chef's kitchen");
}
else if(choice[0].equalsIgnoreCase("no") &&
choice[1].equalsIgnoreCase("no") &&
choice[2].equalsIgnoreCase("no"))
{
System.out.println("Joe's gourmet burgers");
System.out.println("Main Street pizza company");
System.out.println("Corner's cafe");
System.out.println("Mama's fine Italian");
System.out.println("Chef's kitchen");
}
}
}
SCREENSHOT-
output 1:
output 2:
IF YOU HAVE ANY DOUBT
PLEASE COMMENT DOWN BELOW I WILL SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK
YOU!!!!!!!!----------