Advertisement
IvaAnd

CruiseGames

Mar 25th, 2020
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CruiseGames_04 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String name = scanner.nextLine();
  8. int countGames = Integer.parseInt(scanner.nextLine());
  9. double sumPoints = 0;
  10. double sumPointsVolley = 0;
  11. double sumPointsTennis = 0;
  12. double sumPointsBadmin = 0;
  13. double averageVolley = 0;
  14. double averageTennis = 0;
  15. double averageBadmin = 0;
  16. int counterVolley=0;
  17. int counterTennis=0;
  18. int counterBadmin=0;
  19.  
  20. for (int gameNumber = 0; gameNumber < countGames; gameNumber++) {
  21. String gameName = scanner.nextLine();
  22. double points = Double.parseDouble(scanner.nextLine());
  23.  
  24. if (gameName.equals("volleyball")){
  25. points = points * 1.07;
  26. counterVolley++;
  27. sumPointsVolley = sumPointsVolley + points;
  28. averageVolley = sumPointsVolley / counterVolley;
  29. averageVolley = Math.floor(averageVolley);
  30. } else if (gameName.equals("tennis")){
  31. points =points * 1.05;
  32. counterTennis++;
  33. sumPointsTennis = sumPointsTennis + points;
  34. averageTennis = sumPointsTennis/counterTennis;
  35. averageVolley = Math.floor(averageVolley);
  36. }else if (gameName.equals("badminton")){
  37. points = points * 1.02;
  38. counterBadmin++;
  39. sumPointsBadmin = sumPointsBadmin + points;
  40. averageBadmin = sumPointsBadmin/counterBadmin;
  41. averageBadmin = Math.floor((averageBadmin));
  42. }
  43. sumPoints = sumPointsVolley+sumPointsTennis+sumPointsBadmin;
  44.  
  45. }
  46.  
  47. sumPoints = Math.floor(sumPoints);
  48.  
  49. if (averageVolley >= 75 && averageTennis>=75 && averageBadmin>=75){
  50. System.out.printf("Congratulations, %s! You won the cruise games with %.0f points.",name, sumPoints);
  51.  
  52.  
  53. }else {
  54. System.out.printf("Sorry, %s, you lost. Your points are only %.0f.", name, sumPoints);
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement