Advertisement
Spocoman

Basketball Tournament

Sep 1st, 2024 (edited)
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 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 win = 0, lost = 0;
  7.  
  8.         String tournament;
  9.         while (!(tournament = scanner.nextLine()).equals("End of tournaments")) {
  10.             int games = Integer.parseInt(scanner.nextLine());
  11.             for (int game = 1; game <= games; game++) {
  12.                 int team1 = Integer.parseInt(scanner.nextLine());
  13.                 int team2 = Integer.parseInt(scanner.nextLine());
  14.                 if (team1 > team2) {
  15.                     System.out.printf("Game %d of tournament %s: win with %d points.\n", game, tournament, team1 - team2);
  16.                     win++;
  17.                 } else {
  18.                     System.out.printf("Game %d of tournament %s: lost with %d points.\n", game, tournament, team2 - team1);
  19.                     lost++;
  20.                 }
  21.             }
  22.         }
  23.  
  24.         System.out.printf("%.2f%% matches win\n", 1.0 * win / (win + lost) * 100);
  25.         System.out.printf("%.2f%% matches lost\n", 1.0 * lost / (win + lost) * 100);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement