Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package S4_ForLoops;
- import java.util.Scanner;
- public class TennisRanklist {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int tournamentsCount = Integer.parseInt(scanner.nextLine());
- int startingPoints = Integer.parseInt(scanner.nextLine());
- int tournamentsPoints = 0;
- int winsCount = 0;
- for (int i = 1; i <= tournamentsCount; i++) {
- // read match result
- String result = scanner.nextLine();
- // add points according to match result
- switch(result) {
- case "W":
- // winsCount += 1;
- winsCount++;
- tournamentsPoints += 2000;
- break;
- case "F":
- tournamentsPoints += 1200;
- break;
- case "SF":
- tournamentsPoints += 720;
- break;
- }
- }
- // find needed variables
- int allPointsAfterTournaments = startingPoints + tournamentsPoints;
- int averagePointsFromTournaments = tournamentsPoints / tournamentsCount;
- double percentWonTournaments = 1.0*winsCount / tournamentsCount * 100;
- // print results
- System.out.printf("Final points: %d%n", allPointsAfterTournaments);
- System.out.printf("Average points: %d%n", averagePointsFromTournaments);
- System.out.printf("%.2f%%", percentWonTournaments);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement