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