Advertisement
veronikaaa86

02. Football Results

Apr 9th, 2022
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class LiveDemo {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String firstGameResult = scanner.nextLine();
  8. String secondGameResult = scanner.nextLine();
  9. String thirdGameResult = scanner.nextLine();
  10.  
  11. int countWon = 0;
  12. int countLost = 0;
  13. int countDrawn = 0;
  14.  
  15. char firstGameHost = firstGameResult.charAt(0);
  16. char firstGameGuest = firstGameResult.charAt(2);
  17. if (firstGameHost > firstGameGuest) {
  18. countWon++;
  19. } else if (firstGameGuest > firstGameHost) {
  20. countLost++;
  21. } else {
  22. countDrawn++;
  23. }
  24.  
  25. char secondGameHost = secondGameResult.charAt(0);
  26. char secondGameGuest = secondGameResult.charAt(2);
  27. if (secondGameHost > secondGameGuest) {
  28. countWon++;
  29. } else if (secondGameGuest > secondGameHost) {
  30. countLost++;
  31. } else {
  32. countDrawn++;
  33. }
  34.  
  35. char thirdGameHost = thirdGameResult.charAt(0);
  36. char thirdGameGuest = thirdGameResult.charAt(2);
  37. if (thirdGameHost > thirdGameGuest) {
  38. countWon++;
  39. } else if (thirdGameGuest > thirdGameHost) {
  40. countLost++;
  41. } else {
  42. countDrawn++;
  43. }
  44.  
  45. System.out.printf("Team won %d games.%n", countWon);
  46. System.out.printf("Team lost %d games.%n", countLost);
  47. System.out.printf("Drawn games: %d%n", countDrawn);
  48. }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement