Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace MetricConverter
- {
- class Program
- {
- static void Main(string[] args)
- {
- double distance = double.Parse(Console.ReadLine());
- string metric = Console.ReadLine();
- string toMetric = Console.ReadLine();
- double fromInMeters = 0;
- if (metric == "m")
- {
- fromInMeters = distance;
- }
- else if (metric == "mm")
- {
- fromInMeters = distance / 1000;
- }
- else if (metric == "cm")
- {
- fromInMeters = distance / 100;
- }
- else if (metric == "mi")
- {
- fromInMeters = distance / 0.000621371192;
- }
- else if (metric == "in")
- {
- fromInMeters = distance / 39.3700787;
- }
- else if (metric == "km")
- {
- fromInMeters = distance / 0.001;
- }
- else if (metric == "ft")
- {
- fromInMeters = distance / 3.2808399;
- }
- else if (metric == "yd")
- {
- fromInMeters = distance / 1.0936133;
- }
- double result = 0;
- if (toMetric == "m")
- {
- result = distance;
- }
- else if (toMetric == "mm")
- {
- result = fromInMeters * 1000;
- }
- else if (toMetric == "cm")
- {
- result = fromInMeters * 100;
- }
- else if (toMetric == "mi")
- {
- result = fromInMeters * 0.000621371192;
- }
- else if (toMetric == "in")
- {
- result = fromInMeters * 39.3700787;
- }
- else if (toMetric == "km")
- {
- result = fromInMeters * 0.001;
- }
- else if (toMetric == "ft")
- {
- result = fromInMeters * 3.2808399;
- }
- else if (toMetric == "yd")
- {
- result = fromInMeters * 1.0936133;
- }
- Console.WriteLine($"{result:F8}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement