Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String teamName = scanner.nextLine();
- int gamesPlayed = Integer.parseInt(scanner.nextLine());
- int counterGames = 0;
- int totalPoints = 0;
- int goalsDifference = 0;
- int goalsScoredCounter = 0;
- int goaslReceivedCounter = 0;
- while (counterGames != gamesPlayed) {
- int goalsScored = Integer.parseInt(scanner.nextLine());
- int goaslReceived = Integer.parseInt(scanner.nextLine());
- counterGames += 1;
- goalsScoredCounter += goalsScored;
- goaslReceivedCounter += goaslReceived;
- if (goalsScored > goaslReceived) {
- totalPoints += 3;
- } else if (goalsScored == goaslReceived) {
- totalPoints++;
- }
- }
- goalsDifference = goalsScoredCounter - goaslReceivedCounter;
- if (goalsScoredCounter >= goaslReceivedCounter) {
- System.out.printf("%s has finished the group phase with %d points.%n", teamName, totalPoints);
- System.out.printf("Goal difference: %d.", goalsDifference);
- } else {
- System.out.printf("%s has been eliminated from the group phase.%n", teamName);
- System.out.printf("Goal difference: %d.", goalsDifference);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement