cruzeirobg

Workout

Apr 13th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Workout {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int days = Integer.parseInt(scanner.nextLine());
  8. double kmFirstDay = Double.parseDouble(scanner.nextLine());
  9. double kmRun = 0;
  10. double kmRunDay = kmFirstDay;
  11. double difference = 0;
  12. double total = 0;
  13.  
  14. for (int i = 0; i < days; i++) {
  15. double percent = Double.parseDouble(scanner.nextLine());
  16. kmRunDay += percent / 100 * kmRunDay;
  17. kmRun +=kmRunDay;
  18.  
  19. }
  20. total = kmFirstDay + kmRun;
  21.  
  22. difference = (Math.abs(total - 1000));
  23.  
  24. if (total >= 1000) {
  25. System.out.printf("You've done a great job running %.0f more kilometers!", Math.ceil(difference));
  26. } else {
  27. System.out.printf("Sorry Mrs. Ivanova, you need to run %.0f more kilometers", Math.ceil(difference));
  28. }
  29.  
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment