Advertisement
Spocoman

Football Results

Sep 6th, 2024
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int won = 0, lost = 0, drawn = 0,
  7.                 teamOneResult, teamTwoResult;
  8.         String gameResult;
  9.  
  10.         for (int i = 0; i < 3; i++) {
  11.             gameResult = scanner.nextLine();
  12.             teamOneResult = gameResult.charAt(0);
  13.             teamTwoResult = gameResult.charAt(2);
  14.  
  15.             if (teamOneResult > teamTwoResult) {
  16.                 won++;
  17.             } else if (teamTwoResult > teamOneResult) {
  18.                 lost++;
  19.             } else {
  20.                 drawn++;
  21.             }
  22.         }
  23.  
  24.         System.out.println(
  25.                 "Team won " + won + " games.\n"
  26.                 + "Team lost " + lost + " games.\n"
  27.                 + "Drawn games: " + drawn + "\n"
  28.         );
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement