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 n = Integer.parseInt(scanner.nextLine()),
- dayMinutes, totalMinutes = 0, totalCalories = 0;
- double dayDistance, totalDistance = 0;
- String distanceUnit;
- for (int i = 0; i < n; i++) {
- dayMinutes = Integer.parseInt(scanner.nextLine());
- dayDistance = Integer.parseInt(scanner.nextLine());
- distanceUnit = scanner.nextLine();
- if (distanceUnit.equals("m")) {
- dayDistance *= 0.001;
- }
- totalMinutes += dayMinutes;
- totalDistance += dayDistance;
- totalCalories += dayMinutes * 400 / 20;
- }
- System.out.printf("He ran %.2fkm for %d minutes and burned %d calories.", totalDistance, totalMinutes, totalCalories);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement