desislava_topuzakova

Workout

May 27th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. package e_FirstLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Workout {
  6. public static void main(String[] args) {
  7. Scanner console = new Scanner(System.in);
  8.  
  9. int trainingDays = Integer.parseInt(console.nextLine());
  10. double firstDayKm = Double.parseDouble(console.nextLine());
  11.  
  12. double sum = firstDayKm;
  13.  
  14. for (int i = 0; i < trainingDays; i++) {
  15. int percentageRanForADay = Integer.parseInt(console.nextLine());
  16.  
  17. firstDayKm*= 1 + percentageRanForADay / 100.0;
  18. sum += firstDayKm;
  19.  
  20. }
  21. if(sum >= 1000){
  22. System.out.printf("You've done a great job running %.0f more kilometers!", Math.abs(Math.ceil(sum - 1000.00)));
  23. } else {
  24. System.out.printf("Sorry Mrs. Ivanova, you need to run %.0f more kilometers", Math.abs(Math.floor(sum - 1000.00)));
  25. }
  26. }
  27. }
Add Comment
Please, Sign In to add comment