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