Advertisement
Spocoman

Running In The Park

Sep 9th, 2024
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 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 n = Integer.parseInt(scanner.nextLine()),
  7.                 dayMinutes, totalMinutes = 0, totalCalories = 0;
  8.         double dayDistance, totalDistance = 0;
  9.         String distanceUnit;
  10.  
  11.         for (int i = 0; i < n; i++) {
  12.             dayMinutes = Integer.parseInt(scanner.nextLine());
  13.             dayDistance = Integer.parseInt(scanner.nextLine());
  14.             distanceUnit = scanner.nextLine();
  15.             if (distanceUnit.equals("m")) {
  16.                 dayDistance *= 0.001;
  17.             }
  18.             totalMinutes += dayMinutes;
  19.             totalDistance += dayDistance;
  20.             totalCalories += dayMinutes * 400 / 20;
  21.         }
  22.  
  23.         System.out.printf("He ran %.2fkm for %d minutes and burned %d calories.", totalDistance, totalMinutes, totalCalories);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement