Advertisement
veronikaaa86

02. Football Results

Jun 24th, 2023
742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. package examPrep;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P02FootballResults {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int countWon = 0;
  10.         int countLost = 0;
  11.         int countTie = 0;
  12.         for (int i = 0; i < 3; i++) {
  13.             String gameResult = scanner.nextLine();
  14.  
  15.             char firstPoints = gameResult.charAt(0);
  16.             char secondPoints = gameResult.charAt(2);
  17.  
  18.             if (firstPoints > secondPoints) {
  19.                 countWon++;
  20.             } else if (firstPoints < secondPoints) {
  21.                 countLost++;
  22.             } else {
  23.                 countTie++;
  24.             }
  25.         }
  26.  
  27.         System.out.printf("Team won %d games.%n", countWon);
  28.         System.out.printf("Team lost %d games.%n", countLost);
  29.         System.out.printf("Drawn games: %d%n", countTie);
  30.  
  31.  
  32.     }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement