Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package JavaFundamentals.MidExam27_02;
- import java.util.Scanner;
- public class Problem1 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double neededExperience = Double.parseDouble(scanner.nextLine());
- int battlesCount = Integer.parseInt(scanner.nextLine());
- int battleMore = 0;
- int battleLess = 0;
- int battleInRow15 = 0;
- for (int i = 0; i <battlesCount ; i++) {
- double experiencedPerBattle=Double.parseDouble(scanner.nextLine());
- battleMore ++;
- battleLess ++;
- battleInRow15 ++;
- if (battleMore == 3){
- experiencedPerBattle += (experiencedPerBattle*0.15);
- battleMore = 0;
- }
- if (battleLess == 5){
- experiencedPerBattle -= experiencedPerBattle*0.1;
- battleLess = 0;
- }if (battleInRow15 == 15){
- experiencedPerBattle += experiencedPerBattle*0.05;
- }
- neededExperience -= experiencedPerBattle;
- if (neededExperience <= 0){
- System.out.printf("Player successfully collected his needed experience for %d battles.",i+1);
- return;
- }
- }
- System.out.printf("Player was not able to collect the needed experience, %.2f more needed.",neededExperience);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement