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