Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TrialExam16Dec18;
- import java.util.Scanner;
- public class Task_5 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int startPeople = Integer.parseInt(scanner.nextLine());
- int nStations = Integer.parseInt(scanner.nextLine());
- int sumIn = 0;
- int sumOut = 0;
- for (int i = 1; i <= nStations; i++) {
- int nOut = Integer.parseInt(scanner.nextLine());
- int nIn = Integer.parseInt(scanner.nextLine());
- if (i % 2 == 1) {
- nIn += 2;
- }
- if (i % 2 == 0) {
- nOut += 2;
- }
- sumIn += nIn;
- sumOut += nOut;
- }
- int finalN = startPeople + sumIn - sumOut;
- System.out.printf("The final number of passengers is : %d", finalN);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement