java

Write a java program using Scanner to help you decide what to do this weekend

```I need help with when asking the questions how do i get the question answered i think my teacher what me to use yes or no. how to i get the program to understand the yes or no and letting that equal true or false. below is the question and under that will be the code i already have.
Decision Trees
Imagine you only ever do three things at the weekend: go shopping, watch a movie, or just stay in. What you do depends on three things: the weather (good or bad); how much money you have (rich or poor) and whether your parents are visiting. You say to your yourself: if my parents are visiting, we'll go to the cinema. If they're not visiting and the weather's good and I'm rich, then I'll go shopping. If they're not visiting, and the weather's good and I'm poor, then I will go to the cinema. If they're not visiting and the weather is bad and I'm rich, I'll go to the cinema. If they're not visiting and the weather is bad and I'm poor, I'll stay in.
Create a program asking whether the parents are visiting, whether the weather is good, and whether you are rich or poor. Your program should print "go to the cinema" "go shopping" or "stay in" as appropriate.
Hint: There are two possibilities for the "Parents visiting?" question, two for the "is weather good?" question, and two for the "are you rich?" question. That gives eight possible cases:
Truth Table for Did You Ever Have to Make Up Your Mind? Are parents visiting? Is the weather good? Are you rich? What you do
y y y
y y n
y n y
y n n
n y y
n y n
n n y
n n n
public class WhatWeDoing {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int N;
int Y;
boolean parentsVisiting = false;
boolean weatherGood = false;
boolean imRich = false;
//prompt user to answer questions yes or no
System.out.print("Are Parents Visiting? Y or N ");
int parents = input.nextInt();
System.out.print("Is the Weather Good? Y or N");
int weather = input.nextInt();
System.out.print("Are You Rich? Y or N");
int Rich = input.nextInt();
{
if (parentsVisiting == false && weatherGood == true && imRich == true) {
System.out.println("Go Shopping! ");
} else if (parentsVisiting == false && weatherGood == false && imRich == false) {
System.out.println("Stay in!");
} else {
System.out.println("Cinema!");
}
}
System.out.println("What you should do is: ");
}
}
```
```You can use input.next().equals and then set your boolean accordingly.
import java.util.Scanner;
public class Main {
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 (input.next().equals("Y"))
parentsVisiting = true;
System.out.print("Is the Weather Good? Y or N");
if (input.next().equals("Y"))
weatherGood = true;
System.out.print("Are You Rich? Y or N");
if (input.next().equals("Y"))
imRich = true;
System.out.println("What you should do is: ");
if (!parentsVisiting && weatherGood && imRich) {
System.out.println("Go Shopping! ");
} else if (!parentsVisiting && !weatherGood && !imRich) {
System.out.println("Stay in!");
} else {
System.out.println("Cinema!");
}
}
}
test
Are Parents Visiting? Y or N Y
Is the Weather Good? Y or NN
Are You Rich? Y or NY
Cinema!
```
```First, you should scan 'Strings' or 'chars', as the user was required
Second, a nice way to getting the value:
//in case of 'char':<br>
Boolean a = (parentsVisiting == 'Y');
or:
//in case of 'String':<br>
Boolean a = parentsVisiting.equals("Y");
The "normal" way to do it will be using 'char' if it is just homework.
Solving it with 'String' helps with lower and uppercase, as well as with unexpected input```

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization