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();

                }

  • 相关阅读:
    web.xml配置详解
    oracle按时间创建分区表
    cron表达式详解
    临时表
    配置非安装版tomcat服务
    CodeForces 785 D Anton and School
    CodeForces 601B Lipshitz Sequence
    CodeForces 590C Three States BFS
    CodeForces 592D Super M DP
    CodeForces 507E Breaking Good 2维权重dij
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4374109.html
Copyright © 2011-2022 走看看