Софтуерно Инженерство
Loading...
stenli981 avatar stenli981 1 Точки

Как да форматирам числа до 8 цифри след запетаята и проблем с конвертора

Здравейте как мога да форматирам числа до 8 цифри след запетаята :F8 и ми го подчертава.

и относно  конвертора

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace metric_convert
{
    class Program
    {
        static void Main(string[] args)
        {
            double m = double.Parse(Console.ReadLine());
            string input = (Console.ReadLine());
            string output = (Console.ReadLine());

            double met = 1;
            double mm = 1000;
            double cm = 100;
            double mi = 0.000621371192;
            double inch = 39.3700787;
            double km = 0.001;
            double ft = 3.2808399;
            double yd = 1.0936133;
            double result = 0.0;

            if (input == "m")
            {
                if (output == "mm")
                {
                    Console.WriteLine (Math.Round((m * mm),8));
                }
                if (output == "cm")
                {
                    Console.WriteLine(m * cm);
                }
                if (output == "mi")
                {
                    Console.WriteLine(Math.Round((m * mi),8));
                }
                if (output == "in")
                {
                    Console.WriteLine(m * inch);
                }
                if (output == "km")
                {
                    Console.WriteLine(m * km);
                }
                if (output == "ft")
                {
                    Console.WriteLine(m * ft);
                }
                if (output == "yd")
                {
                    Console.WriteLine(m * yd);
                }
            }
            if (input == "mm")
            {
                if (output == "m")
                {
                    Console.WriteLine(Math.Round((m / mm),8));
                }
                if (output == "cm")
                {
                    Console.WriteLine(Math.Round((m / 10),8));
                }
                if (output == "mi")
                {
                    Console.WriteLine(Math.Round((m * mi),8));
                }
                if (output == "in")
                {
                    Console.WriteLine (Math.Round((m / 25.4),8));
                }
                if (output == "km")
                {
                    
                    Console.WriteLine(Math.Round((m * 0.000001000000),8));
                }
                if (output == "ft")
                {
                    Console.WriteLine(Math.Round((m * 0.0032808399), 8));
                }
                if (output == "yd")
                {
                    Console.WriteLine(Math.Round((m * 0.0010936133), 8));
                }
            }
            if (input == "cm")
            {
                if (output == "m")
                {
                    Console.WriteLine(Math.Round((m /100), 8));
                }
                if (output == "mm")
                {
                    Console.WriteLine(Math.Round((m * 10), 8));
                }
                if (output == "mi")
                {
                    result = result + m * 0.0000062137;
                    Console.WriteLine(Math.Round((result), 8));
                }
                if (output == "in")
                {
                    Console.WriteLine(Math.Round((m * 0.393700787), 8));
                }

            }

 

        }
    }
}

 

 

Когато конвертирам cm до mi ми изписва : 6.21E-06 на сложен 1 cm

 

0
C# OOP Basics
prohause avatar prohause 282 Точки

Колега пробвай с placeholder $"{result:F8}" 

0
stenli981 avatar stenli981 1 Точки

Помогнахте ми. Благодаря!

0
prohause avatar prohause 282 Точки

За нищо

0