Advertisement
Sim0o0na

04. Running In The Park

Apr 30th, 2018
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace RunningInThePark
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int n = int.Parse(Console.ReadLine());
  13.             int mins = 0;
  14.             double ranDistance = 0;
  15.             int calories = 0;
  16.             for (int i = 0; i < n; i++)
  17.             {
  18.                 int time = int.Parse(Console.ReadLine());
  19.                 mins += time;
  20.                 double distance = double.Parse(Console.ReadLine());
  21.                 string unit = Console.ReadLine();
  22.                 if (unit == "km")
  23.                     distance *= 1;
  24.                 else if (unit == "m")
  25.                     distance *= 0.001;
  26.                 ranDistance += distance;
  27.                 calories += time * 400 / 20;
  28.             }
  29.  
  30.             Console.WriteLine($"He ran {ranDistance:f2}km for {mins} minutes and burned {calories} calories.");
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement