0

I am trying to fix this program, and no matter what I do, it prints every single response even if the conditions are not met. I feel like I took a long way around. Help would be great

import java.util.Scanner;


public class NoahJetRoberts_Project_2{


    public static void main(String args[]){

        Scanner in = new Scanner(System.in);

        System.out.println("Hello! this programe will help you decide where your party can eat!");
        System.out.println("Is anyone here a vegan? (yes or no)");
        String vegan = in.nextLine();
        System.out.println("Okay, does anyone need gluten-free food?(yes or no)");
        String GF = in.nextLine();
        System.out.println("Is anyone a vegetarian?(yes or no)");
        String vege = in.nextLine();
        if (vegan.equals("yes") && GF.equals("yes") && vege.equals("yes"));
        {
            System.out.println("Okay, you can go to The Chef’s Kitchen and Corner Café");
        }

        if (vegan.equals("no") && GF.equals("no") && vege.equals("no"));
        {
            System.out.println("Okay, you can go anywhere");
        }
        if (vegan.equals("yes") && GF.equals("no") && vege.equals("no"));
        {
            System.out.println("Okay, you can go to The Chef’s Kitchen and Corner Café");
        }
        if (vegan.equals("no") && GF.equals("yes") && vege.equals("no"));
        {
            System.out.println("Okay, you can go to The Main Street Pizza Company and Corner Café and The Chef’s Kitchen");
        }
        if (vegan.equals("no") && GF.equals("no") && vege.equals("yes"));
        {
            System.out.println("You can go to The Chef’s Kitchen, Mama’s Fine Italian, Corner Café, Main Street Pizza Company");
        }
        if (vegan.equals("yes") && GF.equals("yes") && vege.equals("no"));
        {
            System.out.println("Okay, you can go to The Chef’s Kitchen and Corner Café");
        }
        if (vegan.equals("yes") && GF.equals("no") && vege.equals("yes"));
        {
            System.out.println("Okay, you can go to The Chef’s Kitchen and Corner Café");
        }

        if (vegan.equals("no") && GF.equals("yes") && vege.equals("yes"));
        {
            System.out.println("Okay, you can go to The Chef’s Kitchen, Corner Café, Main Street Pizza Company");
        }


        System.out.println("Thank you! Have a great time!");
        }


    }
Turing85
  • 18,217
  • 7
  • 33
  • 58
Zera Sada
  • 9
  • 1
  • When I paste your code into my Eclipse, it points to the `;` (semicolon) after `if (vegan.equals("yes") && GF.equals("yes") && vege.equals("yes"))` and says *Empty control-flow statement*. While the message may not be very clear and in particular not to a new programmer, most IDEs are trying to be helpful in this way, and with time you will learn to interpret what your IDE is telling you. I encourage you to start now. – Ole V.V. Sep 27 '19 at 19:25

1 Answers1

2
 if (vegan.equals("no") && GF.equals("no") && vege.equals("no"));
    {
        System.out.println("Okay, you can go anywhere");
    }

for example (this goes for all other situations as well), remove the ";" at the end.

because it will separate your if-clause from the following code-block. Like this:

if (vegan.equals("no") && GF.equals("no") && vege.equals("no")){
            System.out.println("Okay, you can go anywhere");
        }
GitPhilter
  • 171
  • 9
  • @Zera Sada Typically if something you write requires you to use brackets such as `{` and `}`, you do not need a semicolon `;`. Just like your `class` or `main`. – Nexevis Sep 27 '19 at 19:24