Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. public class E01ExperienceGaining {
  2. public static void main(String[] args) {
  3. Scanner sc = new Scanner(System.in);
  4.  
  5. double expNeeded = Double.parseDouble(sc.nextLine());
  6. double expTotal= 0;
  7. int battles = Integer.parseInt(sc.nextLine());
  8.  
  9. for (int i = 1; i <= battles; i++) {
  10. double exp = Double.parseDouble(sc.nextLine());
  11.  
  12. if (i % 3 == 0) {
  13. exp *= 1.15;
  14. }
  15.  
  16. if (i % 5 == 0) {
  17. exp *= 0.9;
  18. }
  19.  
  20. expTotal += exp;
  21.  
  22. if (expTotal >= expNeeded) {
  23.  
  24. System.out.printf("Player successfully collected his needed experience for %d battles.", i);
  25. return;
  26. }
  27. }
  28.  
  29. System.out.printf("Player was not able to collect the needed experience, %.2f more needed.", expNeeded - expTotal);
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement