Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class GroupStage {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String team = scanner.nextLine();
- int nMatch = Integer.parseInt(scanner.nextLine());
- int sumPoints = 0;
- int sumDiff = 0;
- int count = 1;
- int sumGoalIn = 0;
- int sumGoalTo = 0;
- while (count <= nMatch) {
- int points = 0;
- int goalTo = Integer.parseInt(scanner.nextLine());
- int goalIn = Integer.parseInt(scanner.nextLine());
- count++;
- if (goalTo > goalIn) {
- points = 3;
- } else if (goalTo == goalIn) {
- points = 1;
- }
- sumPoints += points;
- int diff = goalTo - goalIn;
- sumDiff += diff;
- sumGoalIn += goalIn;
- sumGoalTo += goalTo;
- }
- if (sumGoalTo >= sumGoalIn) {
- System.out.printf("%s has finished the group phase with %d points.%n",
- team, sumPoints);
- System.out.printf("Goal difference: %d.", sumDiff);
- } else {
- System.out.printf("%s has been eliminated from the group phase.%n",
- team);
- System.out.printf("Goal difference: %d.", sumDiff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement