Advertisement
Ivelin_Arsov

CruiseGames

Feb 22nd, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.90 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CruiseGames {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         String playerName = scan.nextLine();
  7.         int gamePlayed = Integer.parseInt(scan.nextLine());
  8.         double multiplayedPoints = 0;
  9.         double totalPoints = 0;
  10.         double volleyballPoints = 0;
  11.         double tennisPoints = 0;
  12.         double badmintonPoints = 0;
  13.         for (int i = 0; i < gamePlayed; i++) {
  14.             String currentGame = scan.nextLine();
  15.             int currentPoints = Integer.parseInt(scan.nextLine());
  16.             int volleyballCnt = 0;
  17.             int tennisCnt = 0;
  18.             int badmintonCnt = 0;
  19.             if (currentGame.equals("volleyball")) {
  20.                 volleyballCnt++;
  21.                 multiplayedPoints = currentPoints * 1.07;
  22.                 volleyballPoints +=Math.floor(multiplayedPoints);
  23.                 volleyballPoints /= volleyballCnt;
  24.             } else if (currentGame.equals("tennis")) {
  25.                 tennisCnt++;
  26.                 multiplayedPoints = currentPoints * 1.05;
  27.                 tennisPoints +=Math.floor(multiplayedPoints);
  28.                 tennisPoints /= tennisCnt;
  29.  
  30.             } else if (currentGame.equals("badminton")) {
  31.                 badmintonCnt++;
  32.                 multiplayedPoints = currentPoints * 1.02;
  33.                 badmintonPoints +=Math.floor(multiplayedPoints);
  34.                 badmintonPoints /= badmintonCnt;
  35.             }
  36.  
  37.             totalPoints +=(multiplayedPoints);
  38.  
  39.         }
  40.         if (volleyballPoints >= 75 && tennisPoints >= 75 && badmintonPoints >= 75) {
  41.             System.out.printf("Congratulations, %s! You won the cruise games with %f points.", playerName, Math.floor(totalPoints));
  42.         } else {
  43.             System.out.printf("Sorry, %s, you lost. Your points are only %f.", playerName, Math.floor(totalPoints));
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement