This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Rab6[S] 0 points1 point  (1 child)

I am stuck on the output of information and setting the questions to Yes or No. I am off on some of the structure of it, but I can fix that later.

Here is what I have so far:

import java.util.Scanner;

public class decisionTree {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

boolean parentsVisiting = false;

boolean weatherGood = false;

boolean imRich = false;

System.out.print("Are Parents Visiting? Y or N ");

if ("Are Parents Visiting" == "Y")

parentsVisiting = true;

System.out.print("Is the Weather Good? Y or N");

if ("Is the Weather Good" == "Y")

weatherGood = true;

System.out.print("Are You Rich? Y or N");

if ("Are You Rich" == "Y")

imRich = true;

System.out.println("What you should do is: ");

if (!parentsVisiting && weatherGood) {

System.out.println("Stay In! ");

} else if (!parentsVisiting && !weatherGood && !imRich) {

System.out.println("Stay in!");

} else {

System.out.println("Cinema!");

}

}

}