Advertisement
Spocoman

08. Tennis Ranklist

Aug 27th, 2024
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TennisRanklist {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int tournamentCount = Integer.parseInt(scanner.nextLine());
  7.         int points = Integer.parseInt(scanner.nextLine());
  8.         int tournamentPoints = 0, win = 0;
  9.  
  10.         for (int i = 0; i < tournamentCount; i++) {
  11.             String currentTournament = scanner.nextLine();
  12.  
  13.             switch (currentTournament) {
  14.                 case "W" -> {
  15.                     tournamentPoints += 2000;
  16.                     win++;
  17.                 }
  18.                 case "F" -> tournamentPoints += 1200;
  19.                 case "SF" -> tournamentPoints += 720;
  20.             }
  21.         }
  22.  
  23.         System.out.printf("Final points: %d\n", points + tournamentPoints);
  24.         System.out.printf("Average points: %d\n", (int)(tournamentPoints / tournamentCount));
  25.         System.out.printf("%.2f%%\n", 100.0 * win / tournamentCount);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement