Advertisement
galinyotsev123

ProgBasicsExam9and10March2019-E02footballResults

Mar 11th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 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 strFootballResult = scanner.nextLine();
  9. String[] goals = strFootballResult.split(":");
  10.  
  11. int firstTeamGoals = Integer.parseInt(goals[0]);
  12. int secondTeamGoals = Integer.parseInt(goals[1]);
  13.  
  14. int wins = 0;
  15. int draws = 0;
  16. int losts = 0;
  17.  
  18. if (firstTeamGoals > secondTeamGoals) {
  19. wins++;
  20. } else if (firstTeamGoals < secondTeamGoals) {
  21. losts++;
  22. } else {
  23. draws++;
  24. }
  25.  
  26. String strFootballResult2 = scanner.nextLine();
  27. String[] goals2 = strFootballResult2.split(":");
  28.  
  29. int firstTeamGoals2 = Integer.parseInt(goals2[0]);
  30. int secondTeamGoals2 = Integer.parseInt(goals2[1]);
  31.  
  32.  
  33. if (firstTeamGoals2 > secondTeamGoals2) {
  34. wins++;
  35. } else if (firstTeamGoals2 < secondTeamGoals2) {
  36. losts++;
  37. } else {
  38. draws++;
  39. }
  40.  
  41. String strFootballResult3 = scanner.nextLine();
  42. String[] goals3 = strFootballResult3.split(":");
  43.  
  44. int firstTeamGoals3 = Integer.parseInt(goals3[0]);
  45. int secondTeamGoals3 = Integer.parseInt(goals3[1]);
  46.  
  47. if (firstTeamGoals3 > secondTeamGoals3) {
  48. wins++;
  49. } else if (firstTeamGoals3 < secondTeamGoals3) {
  50. losts++;
  51. } else {
  52. draws++;
  53. }
  54.  
  55. System.out.printf("Team won %d games.%n", wins);
  56. System.out.printf("Team lost %d games.%n", losts);
  57. System.out.printf("Drawn games: %d%n", draws);
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement