Question: import java.util.Scanner; public class GateKeeper { public static boolean canBoard(boolean param1, int p2, double i_forget) { final int constant = 120; final int maX =

import java.util.Scanner; public class GateKeeper {

public static boolean canBoard(boolean param1, int p2, double i_forget) { final int constant = 120; final int maX = 196; final double MASS = 200; boolean out; out = false; if (param1 && i_forget = maX) { out = true; } } return out; }

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

String again;

boolean atLeast10; int height; double weight;

System.out.println("ROLLER COASTER GATE KEEPER");

do { System.out.print("Are you at least 10 years old (true/false)? "); atLeast10 = sc.nextBoolean();

System.out.print("Height (whole cm): "); height = sc.nextInt();

System.out.print("Weight (to nearest half kg): "); weight = sc.nextDouble();

if (canBoard(atLeast10, height, weight)) { System.out.println("Welcome aboard"); } else { System.out.println("Sorry you may not board"); }

System.out.print("Process another person (y)? "); again = sc.next(); } while(again.equals("y"));

} }

Currently the code does not work correctly. The system should allow patrons to board the roller coaster if they are at least 10 years old, between 120 and 196cm tall, and weigh less than 200kg.

The following tests indicate what the answers should be for different age, height and weight values (the names refer to the variables in main()). Use these tests to locate the current issue with the code. You may also wish to (temporarily) insert additional println() statements to help identify partial success in the code's logic.

import java.util.Scanner; public class GateKeeper {public static boolean canBoard(boolean param1, int p2,

atLeastl 0 height weight Expected result false 150 50.5 false false 90 50.5 false true 150 50.5 true true 90 50.5 false true 180 120.0 true true 200 120.0 false true 180 201 .5 false

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!