利用if else 来计算车费

static void Main(string[] args)
        {
            while (true)
            {
                double x,y;
                Console.Write("请输入坐车的距离:");
                x = Convert.ToDouble(Console.ReadLine());
                if (x>0&&x <= 3)
                {
                    Console.WriteLine("您的车费为8元");
                }
                else if (x > 3 && x <= 5)
                {
                    Console.WriteLine("您的车费为"+(8+(x-3)*1.2)+"元");  //注意运算要加括号
                }

else if (x > 5)
                {
                    Console.WriteLine("您的车费为" + (10.4+ (x - 5) * 1.5) + "元");
                }

else
                {
                    Console.WriteLine("请输入正确的距离");
                }

Console.ReadLine();

}

上一篇:python linux crontab计划任务设置


下一篇:中国空气质量在线监测平台加密数据爬取