Advertisement
stoyanoff

FootballResults

Jun 16th, 2020
1,176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. import java.lang.reflect.Array;
  2. import java.util.Scanner;
  3.  
  4. public class FootballResults {
  5.     public static void main(String[] args) {
  6.         Scanner myScan = new Scanner(System.in);
  7.  
  8.         String result;
  9.         int won = 0;
  10.         int lost = 0;
  11.         int draw = 0;
  12.         for (int count = 1; count <= 3; count++) {
  13.             result = myScan.nextLine();
  14.             int teamHome = Integer.parseInt(result.charAt(0) + "");
  15.             int teamAway = Integer.parseInt(result.charAt(2) + "");
  16.             if (teamHome > teamAway) {
  17.                 won++;
  18.             } else if (teamHome == teamAway) {
  19.                 draw++;
  20.             } else {
  21.                 lost++;
  22.             }
  23.  
  24.         }
  25.         System.out.printf("Team won %d games.\n", won);
  26.         System.out.printf("Team lost %d games.\n", lost);
  27.         System.out.printf("Drawn games: %d", draw);
  28.  
  29.  
  30.     }
  31.  
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement