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 lenght = double.Parse(Console.ReadLine());
- var inputType = Console.ReadLine();
- var outputType = Console.ReadLine();
- var lenghtInMeters = 0.0;
- if(inputType == "m")
- {
- lenghtInMeters = lenght / 1;
- }
- else if (inputType == "mm")
- {
- lenghtInMeters = lenght / 1000;
- }
- else if (inputType == "cm")
- {
- lenghtInMeters = lenght / 100;
- }
- else if (inputType == "mi")
- {
- lenghtInMeters = lenght / 0.000621371192;
- }
- else if (inputType == "in")
- {
- lenghtInMeters = lenght / 39.3700787;
- }
- else if (inputType == "km")
- {
- lenghtInMeters = lenght / 0.001;
- }
- else if (inputType == "ft")
- {
- lenghtInMeters = lenght / 3.2808399;
- }
- else
- {
- lenghtInMeters = lenght / 1.0936133;
- }
- var outputLenght = 0.0;
- if (outputType == "m")
- {
- outputLenght = lenghtInMeters * 1;
- }
- else if (outputType == "mm")
- {
- outputLenght = lenghtInMeters * 1000;
- }
- else if (outputType == "cm")
- {
- outputLenght = lenghtInMeters * 100;
- }
- else if (outputType == "mi")
- {
- outputLenght = lenghtInMeters * 0.000621371192;
- }
- else if (outputType == "in")
- {
- outputLenght = lenghtInMeters * 39.3700787;
- }
- else if (outputType == "km")
- {
- outputLenght = lenghtInMeters * 0.001;
- }
- else if (outputType == "ft")
- {
- outputLenght = lenghtInMeters * 3.2808399;
- }
- else
- {
- outputLenght = lenghtInMeters * 1.0936133;
- }
- Console.WriteLine("{0} {1}", outputLenght, outputType);
- }
- }
- }
Add Comment
Please, Sign In to add comment