Advertisement
SIRAKOV4444

Untitled

Feb 28th, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. package com.company;
  2. import java.util.Scanner;
  3. public class Ibiza{
  4. public static void main(String[]args){
  5. Scanner sc=new Scanner(System.in);
  6.  
  7. double neededExp=Double.parseDouble(sc.nextLine());
  8. int CountBattles=Integer.parseInt(sc.nextLine());
  9.  
  10. double TotalExp=0.0;
  11. int count=0;
  12.  
  13. for(int i=1;i<=CountBattles;i++) {
  14. if(neededExp>TotalExp) {
  15. count += 1;
  16. double ExpPerBattle = Double.parseDouble(sc.nextLine());
  17. if (i % 3 == 0) {
  18. TotalExp += (ExpPerBattle * 1.15);
  19. if (i % 5 == 0) {
  20. TotalExp -= (ExpPerBattle * 0.9);
  21. }
  22. }
  23. if (i % 5 == 0) {
  24. TotalExp += (ExpPerBattle * 0.9);
  25. }
  26. if (i % 5 != 0 && i % 3 != 0) {
  27. TotalExp += ExpPerBattle;
  28. }
  29. }else{
  30. System.out.printf("Player successfully collected his needed experience for %d battles.",count);
  31. }
  32. }
  33. if(TotalExp>=neededExp){
  34. System.out.printf("Player successfully collected his needed experience for %d battles.",count);
  35. }else{
  36. double needed=(neededExp-TotalExp)*1.0;
  37. System.out.printf("Player was not able to collect the needed experience, %.2f more needed.",needed);
  38. }
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement