Advertisement
psi_mmobile

Untitled

May 24th, 2022
978
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.14 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.         String match1 = scanner.nextLine();
  5.         String match2 = scanner.nextLine();
  6.         String match3 = scanner.nextLine();
  7.        
  8.         int homeWins = 0;
  9.         int visitorWins = 0;
  10.         int draws = 0;
  11.        
  12.         char homeMatchScore = match1.charAt(0);
  13.         char visitorMatchScore = match1.charAt(2);
  14.        
  15.         if (Character.getNumericValue(homeMatchScore) > Character.getNumericValue(visitorMatchScore)) {
  16.             homeWins++;
  17.         }
  18.         if (Character.getNumericValue(homeMatchScore) < Character.getNumericValue(visitorMatchScore)) {
  19.             visitorWins++;
  20.         }
  21.         if (Character.getNumericValue(homeMatchScore) == Character.getNumericValue(visitorMatchScore)) {
  22.             draws++;
  23.         }
  24.        
  25.         homeMatchScore = match2.charAt(0);
  26.         visitorMatchScore = match2.charAt(2);
  27.        
  28.         if (Character.getNumericValue(homeMatchScore) > Character.getNumericValue(visitorMatchScore)) {
  29.             homeWins++;
  30.         }
  31.         if (Character.getNumericValue(homeMatchScore) < Character.getNumericValue(visitorMatchScore)) {
  32.             visitorWins++;
  33.         }
  34.         if (Character.getNumericValue(homeMatchScore) == Character.getNumericValue(visitorMatchScore)) {
  35.             draws++;
  36.         }
  37.        
  38.         homeMatchScore = match3.charAt(0);
  39.         visitorMatchScore = match3.charAt(2);
  40.        
  41.         if (Character.getNumericValue(homeMatchScore) > Character.getNumericValue(visitorMatchScore)) {
  42.             homeWins++;
  43.         }
  44.         if (Character.getNumericValue(homeMatchScore) < Character.getNumericValue(visitorMatchScore)) {
  45.             visitorWins++;
  46.         }
  47.         if (Character.getNumericValue(homeMatchScore) == Character.getNumericValue(visitorMatchScore)) {
  48.             draws++;
  49.         }
  50.        
  51.         System.out.printf("Team won %d games.\n", homeWins);
  52.         System.out.printf("Team lost %d games.\n", visitorWins);
  53.         System.out.printf("Drawn games: %d", draws);
  54.        
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement