Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Ibiza{
- public static void main(String[]args){
- Scanner sc=new Scanner(System.in);
- double neededExp=Double.parseDouble(sc.nextLine());
- int CountBattles=Integer.parseInt(sc.nextLine());
- double TotalExp=0.0;
- int count=0;
- for(int i=1;i<=CountBattles;i++) {
- if(neededExp>TotalExp) {
- count += 1;
- double ExpPerBattle = Double.parseDouble(sc.nextLine());
- if (i % 3 == 0) {
- TotalExp += (ExpPerBattle * 1.15);
- if (i % 5 == 0) {
- TotalExp -= (ExpPerBattle * 0.9);
- }
- }
- if (i % 5 == 0) {
- TotalExp += (ExpPerBattle * 0.9);
- }
- if (i % 5 != 0 && i % 3 != 0) {
- TotalExp += ExpPerBattle;
- }
- }else{
- System.out.printf("Player successfully collected his needed experience for %d battles.",count);
- }
- }
- if(TotalExp>=neededExp){
- System.out.printf("Player successfully collected his needed experience for %d battles.",count);
- }else{
- double needed=(neededExp-TotalExp)*1.0;
- System.out.printf("Player was not able to collect the needed experience, %.2f more needed.",needed);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement