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 _8.MetricConverter
- {
- class Program
- {
- static void Main(string[] args)
- {
- double distance = double.Parse(Console.ReadLine());
- string currentUnit = Console.ReadLine();
- string wantedUnit = Console.ReadLine();
- double convertedDistance = distance;
- if (currentUnit == "mm")
- {
- convertedDistance = distance / 1000.0;
- }
- else if (currentUnit == "cm")
- {
- convertedDistance = distance / 100.0;
- }
- else if (currentUnit == "mi")
- {
- convertedDistance = distance / 0.000621371192;
- }
- else if (currentUnit == "in")
- {
- convertedDistance = distance / 39.3700787;
- }
- else if (currentUnit == "km")
- {
- convertedDistance = distance / 0.001;
- }
- else if (currentUnit == "ft")
- {
- convertedDistance = distance / 3.2808399;
- }
- else if (currentUnit == "yd")
- {
- convertedDistance = distance / 1.0936133;
- }
- if (wantedUnit == "mm")
- {
- convertedDistance = convertedDistance * 1000.0;
- }
- else if (wantedUnit == "cm")
- {
- convertedDistance = convertedDistance * 100.0;
- }
- else if (wantedUnit == "mi")
- {
- convertedDistance = convertedDistance * 0.000621371192;
- }
- else if (wantedUnit == "in")
- {
- convertedDistance = convertedDistance * 39.3700787;
- }
- else if (wantedUnit == "km")
- {
- convertedDistance = convertedDistance * 0.001;
- }
- else if (wantedUnit == "ft")
- {
- convertedDistance = convertedDistance * 3.2808399;
- }
- else if (wantedUnit == "yd")
- {
- convertedDistance = convertedDistance * 1.0936133;
- }
- Console.WriteLine($"{convertedDistance} {wantedUnit}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement