SHARE
TWEET

Untitled

a guest Jun 25th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace Distance_Calculator
  2. {
  3.     using System;
  4.  
  5.     public class StartUp
  6.     {
  7.         static void Main()
  8.         {
  9.             int steps = int.Parse(Console.ReadLine());
  10.             double lengthOfStep = double.Parse(Console.ReadLine());
  11.             int distance = int.Parse(Console.ReadLine()) * 100;
  12.  
  13.             double travelled = 0;
  14.  
  15.             for (int i = 1; i <= steps; i++)
  16.             {
  17.                 if (i % 5 == 0)
  18.                 {
  19.                     travelled += lengthOfStep * 0.7;
  20.                 }
  21.                 else
  22.                 {
  23.                     travelled += lengthOfStep;
  24.                 }
  25.             }
  26.  
  27.             double percentage = travelled / distance * 100;
  28.             Console.WriteLine($"You travelled {percentage:f2}% of the distance!");
  29.         }
  30.     }
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top