144k views
0 votes
Get user input as a boolean and store it in the variable tallEnough. Also, get user input as a boolean and store it in the variable oldEnough. Then, use the two boolean variables to decide whether the user is able to ride the rollercoaster. The only time the user can ride the rollercoaster is if the responses to both answers is true. Use a logical operator to decide whether the user is eligible to ride. Print true or false depending on whether the user can or can’t ride the rollercoaster.

User Rohunb
by
4.2k points

1 Answer

3 votes

Answer:

I will code in JAVA.

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

boolean tallEnough;

boolean oldEnough;

Scanner input = new Scanner(System.in);

tallEnough = input.nextBoolean(); //wait the input for tallEnough

oldEnough = input.nextBoolean(); //wait the input for OldEnough

if(tallEnough && oldEnough){

System.out.print(true);

} else {

System.out.print(false);

}

}

}

Step-by-step explanation:

First, to accept user inputs you have to import the class Scanner. Then declare both variables before allowing the user to set input values for both boolean variables.

In the if-else statement checks if both variables are true, then prints true. Another case prints always false.

User Dooie
by
4.6k points