Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can some help me write a Java program that only use if-else statement, while loop, scanner and boolean which satisfy the prompt in the picture

image text in transcribed

Can some help me write a Java program that only use if-else statement, while loop, scanner and boolean which satisfy the prompt in the picture above? I have tried so many times but it does not work the way it suppose to be.

Here is my code:

import java.util.Scanner; public class Main { public static void main(String[] args) { String international; String boardingPass; String passport; String driversLicense; String stateID; String otherID; Scanner keyboard; keyboard = new Scanner(System.in); char in; System.out.println("International flight(y): "); international = keyboard.next(); System.out.println("Boarding pass(y): "); boardingPass = keyboard.next(); System.out.println("Passport(y): "); passport = keyboard.next(); System.out.println("Driver's license(y): "); driversLicense = keyboard.next(); System.out.println("State ID(y): "); stateID = keyboard.next(); System.out.println("Other valid government ID(y): "); otherID = keyboard.next(); if ((boardingPass.equals('y')) & ((driversLicense.equals('y')) | (stateID.equals('y')) | (otherID.equals('y')) |(passport.equals('y')))){ System.out.println("Allow Boarding"); } else { System.out.println("Deny Boarding"); } if ((!keyboard.equals('y'))|(!keyboard.equals('n'))){ System.out.println("Incorrect Input"); } } }
to make it work? Put your answer in a text file. D. In order to board a domestic flight, at security you must have a boarding pass and one of the following: a driver's license, a state ID, or some other valid government-issued ID (like a passport). In order to board an international flight, you must have a boarding pass and a passport. Write a program to help the security agent determine whether you can board by answering the following questions: International flight (Y/N): Boarding pass (Y/N): Passport (Y/N): Driver's license (Y/N): State ID (Y/N): Other valid government ID (Y/N): The program should output each statement above on the console and wait each time for the user to type in Y or N. The user has to answer every question. After the last user input is accepted, your program should output one of three things: Deny Boarding Allow Boarding Incorrect Input (if the user typed something other than Y or N for any answer)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

a. When did your ancestors come to the United States?

Answered: 1 week ago

Question

d. What language(s) did they speak?

Answered: 1 week ago

Question

e. What difficulties did they encounter?

Answered: 1 week ago