Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CruiseGames {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String playerName = scan.nextLine();
- int gamePlayed = Integer.parseInt(scan.nextLine());
- double multiplayedPoints = 0;
- double totalPoints = 0;
- double volleyballPoints = 0;
- double tennisPoints = 0;
- double badmintonPoints = 0;
- for (int i = 0; i < gamePlayed; i++) {
- String currentGame = scan.nextLine();
- int currentPoints = Integer.parseInt(scan.nextLine());
- int volleyballCnt = 0;
- int tennisCnt = 0;
- int badmintonCnt = 0;
- if (currentGame.equals("volleyball")) {
- volleyballCnt++;
- multiplayedPoints = currentPoints * 1.07;
- volleyballPoints +=Math.floor(multiplayedPoints);
- volleyballPoints /= volleyballCnt;
- } else if (currentGame.equals("tennis")) {
- tennisCnt++;
- multiplayedPoints = currentPoints * 1.05;
- tennisPoints +=Math.floor(multiplayedPoints);
- tennisPoints /= tennisCnt;
- } else if (currentGame.equals("badminton")) {
- badmintonCnt++;
- multiplayedPoints = currentPoints * 1.02;
- badmintonPoints +=Math.floor(multiplayedPoints);
- badmintonPoints /= badmintonCnt;
- }
- totalPoints +=(multiplayedPoints);
- }
- if (volleyballPoints >= 75 && tennisPoints >= 75 && badmintonPoints >= 75) {
- System.out.printf("Congratulations, %s! You won the cruise games with %f points.", playerName, Math.floor(totalPoints));
- } else {
- System.out.printf("Sorry, %s, you lost. Your points are only %f.", playerName, Math.floor(totalPoints));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement