JAVA 프로그래밍

문제

1층에서 엘리베이터에 탑승 후 엘리베이터에서 내릴 층수를 입력받아 메시지를 출력하는 문제입니다 이를 해결하는 프로그램의 다음 실행상태에 대해 빈칸을 채우세요 

프로그램의 실행순서 및 실행상태

1  public static void main( String[] args ) {  

2   int destinationFloor = scan.nextInt(); 
1층~5층 중 몇 층으로 올라가시나요 : 2

2층으로 올라갑니다. 문이 닫힙니다.

3   int currentFloor = 1;
                              main()
scan  (Scanner) 
destinationFloor  2 
    currentFloor

4   while( currentFloor <= destinationFloor ) {

1층

5    currentFloor++;       
                              main()
scan  (Scanner) 
destinationFloor  2 
    currentFloor

4   while( currentFloor <= destinationFloor ) {

2층

5    currentFloor++;       
                              main()
scan  (Scanner) 
destinationFloor  2 
    currentFloor

4   while( currentFloor <= destinationFloor ) {

딩~동~댕~동~~ 2층입니다. 문이 열립니다

6  }


프로그램 코드

	import java.util.Scanner;
		
	public class Elevator
	{
1		public static void main( String[] args ) { 	
			Scanner scan = new Scanner( System.in );
			System.out.print( "1층~5층 중 몇 층으로 올라가시나요 : " );
2			int destinationFloor = scan.nextInt(); 
		
			System.out.println( destinationFloor + "층으로 올라갑니다. 문이 닫힙니다." );
		
3			int currentFloor = 1;
4			while( currentFloor <= destinationFloor ) {
				System.out.println( currentFloor + "층" );
5				currentFloor++;							
			}
		
			System.out.println( "딩~동~댕~동~~ " + destinationFloor + "층입니다. 문이 열립니다" );
			scan.close();
6		}
	}