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 teamName = scanner.nextLine();
- int games = Integer.parseInt(scanner.nextLine());
- int countGames = 0;
- int points = 0;
- int totalTGoals = 0;
- int totalCompGoals = 0;
- int diffOnGame = 0;
- int totalDifference = 0;
- while (countGames != games) {
- int teamGoals = Integer.parseInt(scanner.nextLine());
- int competitorGoals = Integer.parseInt(scanner.nextLine());
- countGames++;
- diffOnGame = teamGoals - competitorGoals;
- if (teamGoals > competitorGoals ) {
- points += 3;
- totalTGoals += teamGoals;
- totalCompGoals += competitorGoals;
- }
- if (teamGoals == competitorGoals ) {
- points += 1;
- totalTGoals += teamGoals;
- totalCompGoals += competitorGoals;
- }
- if (teamGoals < competitorGoals) {
- points += 0;
- totalTGoals += teamGoals;
- totalCompGoals += competitorGoals;
- }
- totalDifference += diffOnGame;
- }
- if (totalTGoals >= totalCompGoals) {
- System.out.printf("%s has finished the group phase with %d points.%n", teamName, points);
- System.out.printf("Goal difference: %d.", totalDifference);
- } else {
- System.out.printf("%s has been eliminated from the group phase.%n", teamName);
- System.out.printf("Goal difference: %d.", totalDifference);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement