分支语句的使用(比较大小)

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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string comparison;
            Console.WriteLine("Enter a number:");
            double var1 = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Enter another number:");
            double var2 = Convert.ToDouble(Console.ReadLine());
            if (var1 < var2)
                comparison = "less than";
            else if (var1 == var2)
                comparison = "equal to";
            else
                comparison = "greater than";
            Console.WriteLine("The first number is {0} the second number.", comparison);
            Console.ReadKey();
        }
    }
}

 

posted @ 2016-01-17 08:58  _Nestling  阅读(251)  评论(0编辑  收藏  举报