Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Metric_Converter
- {
- class Program
- {
- static void Main(string[] args)
- {
- var metricValue = double.Parse(Console.ReadLine());
- var metricInName = Console.ReadLine();
- var metricOutName = Console.ReadLine();
- byte indexIn = 0;
- byte indexOut = 0;
- string[] metricName = { "m", "mm", "cm", "mi",
- "in", "km", "ft", "yd" };
- double[] metricRate = { 1d, 1000d, 100d, 0.000621371192d,
- 39.3700787d, 0.001d, 3.2808399d, 1.0936133d};
- for (byte i = 0; i < metricName.Length; i++)
- {
- if (metricInName == metricName[i]) indexIn = i;
- if (metricOutName == metricName[i]) indexOut = i;
- }
- double metricOut = metricValue * metricRate[indexOut] /
- metricRate[indexIn];
- Console.WriteLine($"{metricOut:f8}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement