VickSuna

Untitled

Jun 28th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _20190630_Group_1_Distance_Calculator
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10. long steps = long.Parse(Console.ReadLine());
  11. decimal lengthOfStep = decimal.Parse(Console.ReadLine());
  12. long distanceToCover = long.Parse(Console.ReadLine());
  13. decimal distanceCovered = 0;
  14. decimal smallStep = 0;
  15.  
  16. for (int i = 1; i <= steps; i++)
  17. {
  18. if (i % 5 == 0)
  19. {
  20. smallStep = lengthOfStep * 0.70m;
  21. distanceCovered += smallStep;
  22. }
  23. else
  24. {
  25. distanceCovered += lengthOfStep;
  26. }
  27. }
  28.  
  29. distanceCovered /= 100;
  30. decimal percentage = distanceCovered / distanceToCover * 100m;
  31. Console.WriteLine($"You travelled {percentage:f2}% of the distance!");
  32.  
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment