Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Demo {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int countDays = Integer.parseInt(scanner.nextLine());
- double allMoney = 0;
- double countWinsDays = 0;
- double countLosesDays = 0;
- for (int i = 1; i <= countDays; i++) {
- double moneyPerDay = 0;
- double percent = 0;
- double countWinsPerDay = 0;
- double countLosesPerDay = 0;
- String input = scanner.nextLine();
- while (!input.equals("Finish")) {
- String ranking = scanner.nextLine();
- if (ranking.equals("win")) {
- countWinsPerDay++;
- } else if (ranking.equals("lose")) {
- countLosesPerDay++;
- }
- input = scanner.nextLine();
- }
- moneyPerDay = countWinsPerDay * 20;
- countWinsDays += countWinsPerDay;
- countLosesDays += countLosesPerDay;
- if (countWinsPerDay > countLosesPerDay) {
- percent = moneyPerDay * 0.90;
- allMoney += (moneyPerDay - percent) + moneyPerDay;
- } else {
- allMoney += moneyPerDay;
- }
- }
- if (countWinsDays > countLosesDays) {
- double finalSum = allMoney * 1.2;
- System.out.printf("You won the tournament! Total raised money: %.2f", finalSum);
- } else {
- System.out.printf("You lost the tournament! Total raised money: %.2f", allMoney);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement