Advertisement
Spocoman

Running In The Park

Sep 24th, 2023
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int n, dayMinutes, totalMinutes = 0, totalCalories = 0;
  8.     double dayDistance, totalDistance = 0;
  9.     string distanceUnit;
  10.  
  11.     cin >> n;
  12.  
  13.     for (int i = 0; i < n; i++) {
  14.         cin >> dayMinutes;
  15.         cin >> dayDistance;
  16.         cin >> distanceUnit;
  17.         if (distanceUnit == "m")
  18.             dayDistance *= 0.001;
  19.  
  20.         totalMinutes += dayMinutes;
  21.         totalDistance += dayDistance;
  22.         totalCalories += dayMinutes * 400 / 20;
  23.     }
  24.  
  25.     printf("He ran %.2fkm for %i minutes and burned %i calories.", totalDistance, totalMinutes, totalCalories);
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement