Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace DistanceCalculator
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- int allStepsMade = int.Parse(Console.ReadLine());
- double lenghOfOneStepInCentimetres = double.Parse(Console.ReadLine());
- int distanceNeedToTravelInMeters = int.Parse(Console.ReadLine());
- double distanceNeedToTravelInCentimetres = distanceNeedToTravelInMeters * 100;
- double lengOfEveryFifthStep = lenghOfOneStepInCentimetres - (0.3 * lenghOfOneStepInCentimetres);
- double shorterSteps = 0;
- if (allStepsMade >= 5)
- {
- shorterSteps = Math.Truncate((double) allStepsMade / 5);
- }
- double normalSteps = allStepsMade - shorterSteps;
- double madeDistanceInCentimetres = (normalSteps * lenghOfOneStepInCentimetres) + (shorterSteps * lengOfEveryFifthStep);
- double percentageOfDistance = madeDistanceInCentimetres / distanceNeedToTravelInCentimetres * 100;
- Console.WriteLine($"You travelled {percentageOfDistance:F2}% of the distance!");
- }
- }
- }
Add Comment
Please, Sign In to add comment