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 numberGames = Integer.parseInt(scanner.nextLine());
- int w = 0;
- int d = 0;
- int l = 0;
- int points = 0;
- for (int i = 1; i <= numberGames; i++) {
- String result = scanner.nextLine();
- if (result.equals("W")) {
- w++;
- points = points + 3;
- } else if (result.equals("D")) {
- d++;
- points = points + 1;
- } else if (result.equals("L")) {
- l++;
- }
- }
- double percentWinGames = 1.0 * w / numberGames * 100;
- if (numberGames == 0) {
- System.out.printf("%s hasn't played any games during this season.", name);
- } else {
- System.out.printf("%s has won %d points during this season.\n", name, points);
- System.out.println("Total stats:");
- System.out.printf("## W: %d\n", w);
- System.out.printf("## D: %d\n", d);
- System.out.printf("## L: %d\n", l);
- System.out.printf("Win rate: %.2f%%",percentWinGames);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement