Advertisement
veronikaaa86

06. Tournament of Christmas

Dec 5th, 2021
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. package nestedLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06TournamentOfChristmas {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int tournamentDays = Integer.parseInt(scanner.nextLine());
  10.  
  11. double totalProfit = 0;
  12. int countTotalWin = 0;
  13. int countTotalLost = 0;
  14. for (int i = 0; i < tournamentDays; i++) {
  15. double dailyProfit = 0;
  16. int countDailyWinGames = 0;
  17. int countDailyLostGames = 0;
  18.  
  19. String input = scanner.nextLine();
  20. while (!input.equals("Finish")) {
  21. String typeGame = input;
  22. String gameResult = scanner.nextLine();
  23.  
  24. if (gameResult.equals("win")) {
  25. dailyProfit = dailyProfit + 20;
  26. countDailyWinGames++;
  27. } else {
  28. countDailyLostGames++;
  29. }
  30.  
  31. input = scanner.nextLine();
  32. }
  33. if (countDailyWinGames > countDailyLostGames) {
  34. dailyProfit = dailyProfit * 1.10;
  35. }
  36.  
  37. countTotalWin = countTotalWin + countDailyWinGames;
  38. countTotalLost = countTotalLost + countDailyLostGames;
  39.  
  40. totalProfit = totalProfit + dailyProfit;
  41. }
  42.  
  43. if (countTotalWin > countTotalLost) {
  44. System.out.print("You won the tournament! ");
  45. System.out.printf("Total raised money: %.2f", totalProfit * 1.20);
  46. } else {
  47. System.out.print("You lost the tournament! ");
  48. System.out.printf("Total raised money: %.2f", totalProfit);
  49.  
  50. }
  51. }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement