Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P05_FootballTournament {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String teamName = scan.nextLine();
- int gamesCount = Integer.parseInt(scan.nextLine());
- int totalPoints = 0;
- int totalWins = 0;
- int totalDraws = 0;
- for (int i = 0; i < gamesCount; i++) {
- String gameType = scan.nextLine();
- if ("W".equals(gameType)) {
- totalPoints += 3;
- totalWins++;
- } else if ("D".equals(gameType)) {
- totalPoints += 1;
- totalDraws++;
- }
- }
- if (gamesCount == 0) {
- System.out.println(String.format("%s hasn't played any games during this season.", teamName));
- } else {
- double winRate = totalWins * 1.0 / gamesCount * 100;
- System.out.println(String.format("%s has won %d points during this season.", teamName, totalPoints));
- System.out.println("Total stats:");
- System.out.println(String.format("## W: %d", totalWins));
- System.out.println(String.format("## D: %d", totalDraws));
- System.out.println(String.format("## L: %d", gamesCount - totalWins - totalDraws));
- System.out.println(String.format("Win rate: %.2f%%", winRate));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement