zoukankan      html  css  js  c++  java
  • 利用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();

                }

  • 相关阅读:
    求连续序列的最大子序列和
    并查集
    分治法求最近点对
    从n个数里面选择m个数
    AcWing
    AcWing
    AcWing
    AcWing
    2017-2018 ACM-ICPC Latin American Regional Programming Contest
    2016-2017 7th BSUIR Open Programming Contest. Semifinal
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4374109.html
Copyright © 2011-2022 走看看