Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int passengers = Integer.parseInt(scanner.nextLine()),
- stations = Integer.parseInt(scanner.nextLine()),
- outputPassengers, inputPassengers;
- for (int i = 1; i <= stations; i++) {
- outputPassengers = Integer.parseInt(scanner.nextLine());
- inputPassengers = Integer.parseInt(scanner.nextLine());
- passengers += inputPassengers - outputPassengers;
- if (i % 2 == 1) {
- passengers += 2;
- } else {
- passengers -= 2;
- }
- }
- System.out.println("The final number of passengers is : " + passengers);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement