ElevatorSimulation.java.html

  1  import java.util.Scanner;
  2  
  3  /**
  4     This program simulates an elevator panel that skips the 13th floor.
  5  */
  6  public class ElevatorSimulation
  7  {
  8     public static void main(String[] args)
  9     {  
 10        Scanner in = new Scanner(System.in);
 11        System.out.print("Floor: ");
 12        int floor = in.nextInt();
 13  
 14        // Adjust floor if necessary
 15  
 16        int actualFloor;
 17        if (floor > 13)
 18        {  
 19           actualFloor = floor - 1;
 20        }
 21        else
 22        {
 23           actualFloor = floor;
 24        }
 25  
 26        System.out.println("The elevator will travel to the actual floor "
 27           + actualFloor);
 28     }
 29  }