Advertisement
Spocoman

Running In The Park

Sep 24th, 2023
628
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CreditSystem
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int totalMinutes = 0;
  11.             double totalDistance = 0;
  12.             int totalCalories = 0;
  13.  
  14.             for (int i = 0; i < n; i++)
  15.             {
  16.                 int dayMinutes = int.Parse(Console.ReadLine());
  17.                 double dayDistance = double.Parse(Console.ReadLine());
  18.                 string distanceUnit = Console.ReadLine();
  19.                 if (distanceUnit == "m")
  20.                     dayDistance *= 0.001;
  21.  
  22.                 totalMinutes += dayMinutes;
  23.                 totalDistance += dayDistance;
  24.                 totalCalories += dayMinutes * 400 / 20;
  25.             }
  26.  
  27.             Console.WriteLine($"He ran {totalDistance:f2}km for {totalMinutes} minutes and burned {totalCalories} calories.");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement