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);
- String gamer = scanner.nextLine(), game;
- int games = Integer.parseInt(scanner.nextLine()), score,
- volleyballGames = 0, tennisGames = 0, badmintonGames = 0;
- double volleyballScores = 0, tennisScores = 0, badmintonScores = 0;
- for (int i = 0; i < games; i++) {
- game = scanner.nextLine();
- score = Integer.parseInt(scanner.nextLine());
- if (game.equals("volleyball")) {
- volleyballGames++;
- volleyballScores += score * 1.07;
- } else if (game.equals("tennis")) {
- tennisGames++;
- tennisScores += score * 1.05;
- } else {
- badmintonGames++;
- badmintonScores += score * 1.02;
- }
- }
- int averageVolleyballPoints = (int) (volleyballScores / volleyballGames),
- averageTennisPoints = (int) (tennisScores / tennisGames),
- averageBadmintonPoints = (int) (badmintonScores / badmintonGames),
- totalPoints = (int) (volleyballScores + tennisScores + badmintonScores);
- if (averageVolleyballPoints >= 75 && averageTennisPoints >= 75 && averageBadmintonPoints >= 75) {
- System.out.println("Congratulations, " + gamer + "! You won the cruise games with " + totalPoints + " points.");
- } else {
- System.out.println("Sorry, " + gamer + ", you lost. Your points are only " + totalPoints + ".");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement