我最亲爱的说

子非鱼,焉知鱼之乐.

导航

编程实践6-1

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

namespace Goods
{
    class Program
    {
        static void Main(string[] args)
        {
            double dblWeight;


            try
            {
                Console.Write("请输入托运货物的重量:");
                dblWeight = Convert.ToDouble(Console.ReadLine());

                
                Console.WriteLine("货物的重量为{0}KG,托运费用为{1}", dblWeight, jisuan(dblWeight));
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine("输入有误。" + ex.Message);
                Console.ReadKey();
            }
        }
        public static double jisuan(double a)
        {
            double dA;
            switch ((int)(a / 100))
            {
                   
                case 0:
                    dA = 3.5;
                    break;
                case 1:
                    dA = 3.2;
                    break;
                case 2:
                    dA = 3.0;
                    break;
                case 3:
                    dA = 2.8;
                    break;
                default:
                    dA = 2.5;
                    break;
            }
            return a * dA;
        }
    }
}

 

posted on 2012-12-05 11:25  我最亲爱的说  阅读(129)  评论(0编辑  收藏  举报