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

                }

  • 相关阅读:
    py-day2-4 python 集合
    LR_问题_控制器不能使用定义的负载生成器
    LR_问题_无法使用LR的Controller,提示缺少license
    LR_问题_在导入wsdl时出现parsing error
    class, extends和super es6语法
    格式化日期
    CLR
    【sqlserver】批量插入10万数据
    php正则表达式匹配函数
    css overflow
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4374109.html
Copyright © 2011-2022 走看看