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