Advertisement
Spocoman

Tennis Ranklist

Sep 10th, 2024
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 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 numberOfTournaments = Integer.parseInt(scanner.nextLine()),
  7.                 startPoints = Integer.parseInt(scanner.nextLine()),
  8.                 tournamentPoints = 0, gamesWon = 0;
  9.         String currentTournament;
  10.        
  11.         for (int i = 0; i < numberOfTournaments; i++) {
  12.             currentTournament = scanner.nextLine();
  13.             if (currentTournament.equals("W")) {
  14.                 tournamentPoints += 2000;
  15.                 gamesWon++;
  16.             } else if (currentTournament.equals("F")) {
  17.                 tournamentPoints += 1200;
  18.             } else {
  19.                 tournamentPoints += 720;
  20.             }
  21.         }
  22.  
  23.         System.out.printf("Final points: %d\n", startPoints + tournamentPoints);
  24.         System.out.printf("Average points: %d\n", (int) (1.0 * tournamentPoints / numberOfTournaments));
  25.         System.out.printf("%.2f%%\n", 100.0 * gamesWon / numberOfTournaments);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement