desislava_topuzakova

Untitled

Sep 27th, 2021
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FootballResults {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String firstMatch = scanner.nextLine();
  8. String secondMatch = scanner.nextLine();
  9. String thirdMatch = scanner.nextLine();
  10.  
  11. int won = 0;
  12. int lost = 0;
  13. int equal = 0;
  14.  
  15. // ASCII comparison
  16. if (firstMatch.charAt(0) > firstMatch.charAt(2)) won++;
  17. else if (firstMatch.charAt(0) < firstMatch.charAt(2)) lost++;
  18. else equal++;
  19.  
  20. // ASCII comparison
  21. if (secondMatch.charAt(0) > secondMatch.charAt(2)) won++;
  22. else if (secondMatch.charAt(0) < secondMatch.charAt(2)) lost++;
  23. else equal++;
  24.  
  25. // ASCII comparison
  26. if (thirdMatch.charAt(0) > thirdMatch.charAt(2)) won++;
  27. else if (thirdMatch.charAt(0) < thirdMatch.charAt(2)) lost++;
  28. else equal++;
  29.  
  30. System.out.printf("Team won %d games.%n", won);
  31. System.out.printf("Team lost %d games.%n", lost);
  32. System.out.printf("Drawn games: %d", equal);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment