Question: How to solve this Java code? Write a program that reads in two numbers (integers) representing the current floor of an elevator and the desired

How to solve this Java code?

Write a program that reads in two numbers (integers) representing the current floor of an elevator and the desired next floor of the elevator (See section 3.6 of the class text book). It then prints out the action of the elevator (such as going up or going down etc). See the Output to see the exact format. Valid floors are 1 through 20 (except there is no floor 13). Input:

The input will be one or more lines of numbers that have been typed in by the user. Each line is to have two integers separated by a space. These represent the current floor and the desired next floor. Output:

The output will have for each input line one of the following results: invalid floor X same floor going up to floor X going down to floor X Sample Input:

-2 13

2 13

1 20

2 2

5 3

Sample Output:

invalid floor -2

invalid floor 13

going up to floor 20

same floor

going down to floor 3

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 Databases Questions!