Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Exams07072019;
- import java.util.Scanner;
- public class FootballTournament {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String name = scanner.nextLine();
- int number = Integer.parseInt(scanner.nextLine());
- int wCounter = 0;
- int dCounter = 0;
- int lCounter = 0;
- int totalPoints = 0;
- for (int i = 1; i <= number; i++) {
- String result = scanner.nextLine();
- if (result.equals("W")) {
- wCounter++;
- totalPoints = totalPoints + 3;
- } else if (result.equals("D")) {
- dCounter++;
- totalPoints = totalPoints + 1;
- } else {
- lCounter++;
- }
- }
- double winGames = 1.0 * wCounter / (wCounter + dCounter + lCounter) * 100;
- if (number > 0) {
- System.out.printf("%s has won %d points during this season.\n", name, totalPoints);
- System.out.println("Total stats:");
- System.out.printf("## W: %d\n", wCounter);
- System.out.printf("## D: %d\n", dCounter);
- System.out.printf("## L: %d\n", lCounter);
- System.out.printf("Win rate: %.2f%%", winGames);
- } else {
- System.out.println("Chelsea hasn't played any games during this season.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement