Question: Imagine that the floor has safe spaces ( stone ) to step on and dangerous spaces ( lava ) that if you step on you

Imagine that the floor has safe spaces (stone) to step on and dangerous spaces (lava) that if you step on you could get hurt. But this floor is tricky as the safe and dangerous spaces switch (stones become lava and lava becomes stone). In this assignment, you will write a program that simulates a sequence of safe spaces (stones). Your task is to print:
all safe spaces (even numbers) in ascending order first. At this moment lava and stones switch(stones become odd, lava become even).
then all safe spaces (odd numbers now) in decreasing order.
Task
We provide a zip file (find it in Autolab) that contains FloorIsLava.java.
UPDATE and SUBMIT the corresponding file.
Programming
Write a program, FloorIsLava.java, that reads 1 integer argument from the command line.
Expect the input to be an integer value greater than or equals 0.
If the input is 0, nothing is expected to be printed.
The program is expected to print all even numbers up to and including the input value (if even). Once all the even numbers have been printed, it prints all odd numbers in descending order (starting with the input value). Expected Output:
For :
24687531
For :
24681012131197531
For :
(no output) FloorIsLava 8FloorIsLava 13FloorIsLava 0
Executing and Debugging
First navigate to FloorIsLava directory/folder
to compile: javac FloorIsLava.java
to execute: java FloorIsLava [any number]

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!