Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Distance_Calculator
- {
- using System;
- public class StartUp
- {
- static void Main()
- {
- int steps = int.Parse(Console.ReadLine());
- double lengthOfStep = double.Parse(Console.ReadLine());
- int distance = int.Parse(Console.ReadLine()) * 100;
- double travelled = 0;
- for (int i = 1; i <= steps; i++)
- {
- if (i % 5 == 0)
- {
- travelled += lengthOfStep * 0.7;
- }
- else
- {
- travelled += lengthOfStep;
- }
- }
- double percentage = travelled / distance * 100;
- Console.WriteLine($"You travelled {percentage:f2}% of the distance!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement