Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BasktetBallTournamentExam1 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String command = scanner.nextLine();
- int totalMatches = 0;
- int wins = 0;
- while (!"End of tournaments".equals(command)) {
- String teamName = command;
- int matchesAmount = Integer.parseInt(scanner.nextLine());
- for (int i = 1; i <= matchesAmount; i++) {
- int teamDesiPoints = Integer.parseInt(scanner.nextLine());
- int enemyTeamPoints = Integer.parseInt(scanner.nextLine());
- boolean isWinner = teamDesiPoints > enemyTeamPoints;
- if (isWinner) {
- System.out.printf("Game %d of tournament %s: win with %d points.\n", i, teamName, teamDesiPoints - enemyTeamPoints);
- wins++;
- } else {
- System.out.printf("Game %d of tournament %s: lost with %d points.\n", i, teamName, Math.abs(teamDesiPoints - enemyTeamPoints));
- }
- totalMatches++;
- }
- command = scanner.nextLine();
- }
- int defeats = totalMatches - wins;
- double winRate = (wins * 100.0) / totalMatches;
- double loseRate = (defeats * 100.0) / totalMatches;
- System.out.printf("%.2f%% matches win\n", winRate);
- System.out.printf("%.2f%% matches lost\n", loseRate);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement