Advertisement
galinyotsev123

ProgBasicsExam28and29July2018-E04groupStage2

Feb 22nd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. String teamName = scanner.nextLine();
  9. int gamesPlayed = Integer.parseInt(scanner.nextLine());
  10.  
  11. int counterGames = 0;
  12. int totalPoints = 0;
  13. int goalsDifference = 0;
  14. int goalsScoredCounter = 0;
  15. int goaslReceivedCounter = 0;
  16.  
  17. while (counterGames != gamesPlayed) {
  18. int goalsScored = Integer.parseInt(scanner.nextLine());
  19. int goaslReceived = Integer.parseInt(scanner.nextLine());
  20. counterGames += 1;
  21. goalsScoredCounter += goalsScored;
  22. goaslReceivedCounter += goaslReceived;
  23.  
  24. if (goalsScored > goaslReceived) {
  25. totalPoints += 3;
  26. } else if (goalsScored == goaslReceived) {
  27. totalPoints++;
  28. }
  29. }
  30. goalsDifference = goalsScoredCounter - goaslReceivedCounter;
  31.  
  32. if (goalsScoredCounter >= goaslReceivedCounter) {
  33. System.out.printf("%s has finished the group phase with %d points.%n", teamName, totalPoints);
  34. System.out.printf("Goal difference: %d.", goalsDifference);
  35. } else {
  36. System.out.printf("%s has been eliminated from the group phase.%n", teamName);
  37. System.out.printf("Goal difference: %d.", goalsDifference);
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement