Advertisement
chaibs

targil5-elevator

Dec 12th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. package myfirst;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class targil5 {
  6.  
  7.     public static void main(String[] args) {
  8.        
  9.         int e_stop = 5, e_mov = 3, res = 0, user_floor = 0, current_floor = 0;
  10.         Scanner s = new Scanner(System.in);
  11.        
  12.         System.out.println("Please enter your current floor:");
  13.         current_floor = s.nextInt();//get users current floor
  14.         System.out.println("Please enter your destination floor:");
  15.         user_floor = s.nextInt();//get user destination floor
  16.        
  17.         res = e_mov * current_floor + e_stop;//calculate elevator movement with users current floor and elevator stop time  
  18.         res += (current_floor - user_floor) * e_mov;//calculate elevator movement with users current floor and destination floor and adding it to result
  19.         System.out.println("The elevator got to his destination in " + res + " seconds");//result
  20.     }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement