galinyotsev123

ProgBasicsExam28and29July2018-E04groupStage

Dec 28th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E04groupStage {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String team = scanner.nextLine();
  8. int gameCount = Integer.parseInt(scanner.nextLine());
  9.  
  10. int totalScoredGoals = 0;
  11. int totalReceivedGoals = 0;
  12. int points = 0;
  13.  
  14. for (int i = 0; i < gameCount; i++) {
  15. int scoredGoals = Integer.parseInt(scanner.nextLine());
  16. int receivedGoals = Integer.parseInt(scanner.nextLine());
  17.  
  18. if (scoredGoals > receivedGoals){
  19. points +=3;
  20. }
  21. else if(scoredGoals==receivedGoals){
  22. points++;
  23. }
  24. totalScoredGoals += scoredGoals;
  25. totalReceivedGoals += receivedGoals;
  26. }
  27.  
  28. int diff = totalScoredGoals -totalReceivedGoals;
  29.  
  30. if (diff >= 0){
  31. System.out.printf("%s has finished the group phase with %d points.%n"
  32. + "Goal difference: %d.", team, points, diff);
  33. }
  34. else {
  35. System.out.printf("%s has been eliminated from the group phase.%n" + "Goal difference: %d.",team, diff);
  36. }
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment