Advertisement
damesova

Group Stage [Mimi]

Feb 25th, 2019
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class GroupStage {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String team = scanner.nextLine();
  8.         int nMatch = Integer.parseInt(scanner.nextLine());
  9.  
  10.         int sumPoints = 0;
  11.         int sumDiff = 0;
  12.         int count = 1;
  13.         int sumGoalIn = 0;
  14.         int sumGoalTo = 0;
  15.  
  16.         while (count <= nMatch) {
  17.             int points = 0;
  18.             int goalTo = Integer.parseInt(scanner.nextLine());
  19.             int goalIn = Integer.parseInt(scanner.nextLine());
  20.             count++;
  21.  
  22.             if (goalTo > goalIn) {
  23.                 points = 3;
  24.             } else if (goalTo == goalIn) {
  25.                 points = 1;
  26.             }
  27.  
  28.             sumPoints += points;
  29.             int diff = goalTo - goalIn;
  30.             sumDiff += diff;
  31.             sumGoalIn += goalIn;
  32.             sumGoalTo += goalTo;
  33.  
  34.         }
  35.         if (sumGoalTo >= sumGoalIn) {
  36.             System.out.printf("%s has finished the group phase with %d points.%n",
  37.                     team, sumPoints);
  38.             System.out.printf("Goal difference: %d.", sumDiff);
  39.         } else {
  40.             System.out.printf("%s has been eliminated from the group phase.%n",
  41.                     team);
  42.             System.out.printf("Goal difference: %d.", sumDiff);
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement