Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The question is the first picture and my output is the second picture. I can't figure out what is wrong (Java) My code is here:

The question is the first picture and my output is the second picture. I can't figure out what is wrong (Java)

image text in transcribed

image text in transcribed

My code is here:

import java.util.Scanner;

public class AirportInfo {

public static void printAirportInfo(String var1, String var2) { System.out.println(var1 + " is " + var2 + "'s airport code."); }

public static void main (String [] args) { Scanner scnr = new Scanner(System.in); String code1 = scnr.nextLine(); String code2 = scnr.nextLine(); String city1 = scnr.nextLine(); String city2 = scnr.nextLine(); printAirportInfo(code1, city1); printAirportInfo(code2, city2);

} }

Jump to level 1 Read four strings from input and call printAirportinfo0 to output as follows. EX: If the input is WAW PDX Warsaw Portland, then the output is: WAW is Warsaw's airport code. PDX is Portland's airport code. X 1: Compare output Exception in thread "main" java.util. NoSuchElementException: No line found at java.base/java.util.Scanner.nextLine (Scanner.java:1651) at Airportinfo.main (Airportinfo.java:14) Input Your output Your program produced no output Expected output 2: Compare output x Exception in thread "main" java.util.NoSuchElementException: No line found at java.base/java.util.Scanner.nextLine (Scanner.java:1651) at Airportinfo.main (Airportinfo.java:14) Input Your output Your program produced no output Expected output

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_2

Step: 3

blur-text-image_3

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

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

Why does mud fly off a rapidly turning automobile tire?

Answered: 1 week ago

Question

=+What is your native language?

Answered: 1 week ago