Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TournamentofChristmas {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int days = Integer.parseInt(scan.nextLine());
- int wins = 0;
- int loses = 0;
- double money = 0;
- int dayWin = 0;
- int dayLose = 0;
- double sum = 0;
- for(int i = 1; i <= days; i++) {
- while (true) {
- String command = scan.nextLine();
- if (command.equals("Finish")) {
- if(wins > loses){
- money = money + 0.1*money;
- sum += money;
- money = 0;
- wins = 0;
- loses = 0;
- dayWin++;
- }else {
- sum += money;
- money = 0;
- dayLose++;
- }
- break;
- } else {
- String winOrLose = scan.nextLine();
- if(winOrLose.equals("win")){
- money += 20;
- wins++;
- }else if(winOrLose.equals("lose")){
- loses++;
- }
- }
- }
- }
- if(dayWin > dayLose){
- sum = sum + 0.2 * sum;
- System.out.printf("You won the tournament! Total raised money: %.2f", sum);
- }else {
- System.out.printf("You lost the tournament! Total raised money: %.2f", sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement