Конвертировать с Pascal на C# код перевода единиц длины
Формулировка задачи:
помогите перевести в c# пожалуйста)
uses crt;
var w:byte;
l:real;
begin
writeln('В каких единицах ввести длину отрезка');
writeln('1-дециметр');
writeln('2-километр');
writeln('3-метр');
writeln('4-миллиметр');
writeln('5-сантиметр');
readln(w);
write('Введите длину отрезка L=');
readln(l);
case w of
1:write(l/10:0:2,' м');
2:write(l*1000:0:2,' м');
3:write(l:0:2,' м');
4:write(l/1000:0:2,' м');
5:write(l/100:0:2,' м');
else write('Такой единицы нет');
end;
end.Решение задачи: «Конвертировать с Pascal на C# код перевода единиц длины»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("В каких единицах ввести длину отрезка");
Console.WriteLine("1-дециметр");
Console.WriteLine("2-километр");
Console.WriteLine("3-метр");
Console.WriteLine("4-миллиметр");
Console.WriteLine("5-сантиметр");
byte w = byte.Parse(Console.ReadLine());
Console.Write("Введите длину отрезка L=");
double l = double.Parse(Console.ReadLine());
switch(w)
{
case 1: Console.Write(string.Format("{0:N2} м", l / 10)); break;
case 2: Console.Write(string.Format("{0:N2} м", l * 1000)); break;
case 3: Console.Write(string.Format("{0:N2} м", l)); break;
case 4: Console.Write(string.Format("{0:N2} м", l / 1000)); break;
case 5: Console.Write(string.Format("{0:N2} м", l / 100)); break;
default: Console.Write("Такой единицы нет"); break;
}
//
Console.ReadKey();
}
}
}