Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.*;
  4.  
  5. public class Main {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. Scanner scanner = new Scanner(System.in);
  10. int days = Integer.parseInt(scanner.nextLine());
  11. double dailyBounty = Double.parseDouble(scanner.nextLine());
  12. double target = Double.parseDouble(scanner.nextLine());
  13.  
  14. double booty = 0;
  15. for (int i = 1; i <= days; i++) {
  16.  
  17. booty += dailyBounty;
  18. if (i % 3 == 0) {
  19. booty += (dailyBounty * 0.5);
  20. } else if (i % 5 == 0) {
  21. booty -= 0.3 * booty;
  22. }
  23. }
  24.  
  25. if (booty >= target) {
  26. System.out.printf("Ahoy! %.2f plunder gained.", booty);
  27. } else {
  28.  
  29. double procentPlunder = (booty / target) * 100;
  30. System.out.printf("Collected only %.2f%% of the plunder.", procentPlunder);
  31. }
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement