Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package myfirst;
- import java.util.Scanner;
- public class targil5 {
- public static void main(String[] args) {
- int e_stop = 5, e_mov = 3, res = 0, user_floor = 0, current_floor = 0;
- Scanner s = new Scanner(System.in);
- System.out.println("Please enter your current floor:");
- current_floor = s.nextInt();//get users current floor
- System.out.println("Please enter your destination floor:");
- user_floor = s.nextInt();//get user destination floor
- res = e_mov * current_floor + e_stop;//calculate elevator movement with users current floor and elevator stop time
- res += (current_floor - user_floor) * e_mov;//calculate elevator movement with users current floor and destination floor and adding it to result
- System.out.println("The elevator got to his destination in " + res + " seconds");//result
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement