Advertisement
Spocoman

Workout

Nov 27th, 2021 (edited)
107
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 Workout
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int days = int.Parse(Console.ReadLine());
  10.             double kilometers = double.Parse(Console.ReadLine());
  11.             double totalKilometers = kilometers;
  12.  
  13.             for (int i = 0; i < days; i++)
  14.             {
  15.                 double percentage = double.Parse(Console.ReadLine());
  16.                 kilometers *= (100.0 + percentage) / 100;
  17.                 totalKilometers += kilometers;
  18.             }
  19.  
  20.             if (totalKilometers < 1000)
  21.             {
  22.                 Console.WriteLine($"Sorry Mrs.Ivanova, you need to run { 1000 - Math.Floor(totalKilometers)} more kilometers");
  23.             }
  24.             else
  25.             {
  26.                 Console.WriteLine($"You've done a great job running {Math.Ceiling(totalKilometers) - 1000} more kilometers!");
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement