Advertisement
Spocoman

Workout

Sep 10th, 2024
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int days = Integer.parseInt(scanner.nextLine());
  7.         double kilometers = Double.parseDouble(scanner.nextLine()),
  8.                 percentage, totalKilometers = kilometers;
  9.         for (int i = 0; i < days; i++) {
  10.             percentage = Double.parseDouble(scanner.nextLine());
  11.             kilometers *= (100.0 + percentage) / 100;
  12.             totalKilometers += kilometers;
  13.         }
  14.  
  15.         if (totalKilometers < 1000) {
  16.             System.out.println("Sorry Mrs.Ivanova, you need to run " + (1000 - (int) (totalKilometers)) + " more kilometers");
  17.         } else {
  18.             System.out.println("You've done a great job running " + (int) (Math.ceil(totalKilometers) - 1000) + " more kilometers!");
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement