├── README.md └── code /README.md: -------------------------------------------------------------------------------- 1 | This Java program simulates an elevator's movement within a building. It takes the total number of floors, the current floor, and a sequence of actions (U for up, D for down) from the user, then updates the current floor accordingly while ensuring movements are within valid bounds. The program provides feedback on the final floor after processing all actions, including handling edge cases like invalid inputs and movements out of bounds. 2 | -------------------------------------------------------------------------------- /code: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Main 3 | { 4 | public static void main(String[] args) { 5 | Scanner sc = new Scanner(System.in); 6 | System.out.println("Enter Total Number of floors:"); 7 | int floor = sc.nextInt(); 8 | System.out.println("Enter Your current floor"); 9 | int current = sc.nextInt(); 10 | System.out.println("Enter your needed action U/D"); 11 | String str = sc.next(); 12 | char c[] = str.toCharArray(); 13 | for(int i=0;i0) 18 | current--; 19 | } 20 | if(current==0) 21 | System.out.println("You are in the Ground Floor"); 22 | else 23 | System.out.println("You are in the Floor: "+current); 24 | } 25 | } 26 | 27 | 28 | 29 | 30 | --------------------------------------------------------------------------------