Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // Четене на входните данни
- int numTournaments = Integer.parseInt(scanner.nextLine());
- int startingPoints = Integer.parseInt(scanner.nextLine());
- // Инициализация на променливи
- int finalPoints = startingPoints;
- int wonTournaments = 0;
- // Обхождане на всички турнири
- for (int i = 0; i < numTournaments; i++) {
- String tournamentResult = scanner.nextLine();
- if (tournamentResult.equals("W")) {
- finalPoints += 2000;
- wonTournaments++;
- } else if (tournamentResult.equals("F")) {
- finalPoints += 1200;
- } else if (tournamentResult.equals("SF")) {
- finalPoints += 720;
- }
- }
- // Изчисляване на средните точки и процента на спечелени турнири
- int totalPoints = finalPoints - startingPoints;
- int averagePoints = totalPoints / numTournaments;
- double percentageWon = (double) wonTournaments / numTournaments * 100;
- // Извеждане на резултатите
- System.out.println("Final points: " + finalPoints);
- System.out.println("Average points: " + averagePoints);
- System.out.printf("%.2f%%\n", percentageWon);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement