Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package e_FirstLoops;
- import java.util.Scanner;
- public class Workout {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- int trainingDays = Integer.parseInt(console.nextLine());
- double firstDayKm = Double.parseDouble(console.nextLine());
- double sum = firstDayKm;
- for (int i = 0; i < trainingDays; i++) {
- int percentageRanForADay = Integer.parseInt(console.nextLine());
- firstDayKm*= 1 + percentageRanForADay / 100.0;
- sum += firstDayKm;
- }
- if(sum >= 1000){
- System.out.printf("You've done a great job running %.0f more kilometers!", Math.abs(Math.ceil(sum - 1000.00)));
- } else {
- System.out.printf("Sorry Mrs. Ivanova, you need to run %.0f more kilometers", Math.abs(Math.floor(sum - 1000.00)));
- }
- }
- }
Add Comment
Please, Sign In to add comment