Advertisement
desislava_topuzakova

08. Tennis Ranklist

Oct 2nd, 2022
456
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 1 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P08TennisRanklist {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int tournaments = Integer.parseInt(scanner.nextLine());
  10.  
  11. int startPoints = Integer.parseInt(scanner.nextLine());
  12. int points = 0;
  13.  
  14. int winCount = 0;
  15.  
  16. for (int i = 0; i < tournaments; i++) {
  17. String position = scanner.nextLine();
  18.  
  19. if (position.equals("W")){
  20. points += 2000;
  21. winCount++;
  22. }
  23. else if (position.equals("F")){
  24. points += 1200;
  25. }
  26. else if (position.equals("SF")){
  27. points += 720;
  28. }
  29. }
  30.  
  31. System.out.printf("Final points: %s", startPoints + points);
  32. System.out.println();
  33. System.out.printf("Average points: %s",points / tournaments);
  34. System.out.println();
  35. System.out.printf("%.2f%%", 1.0* winCount/ tournaments * 100);
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement