当前位置:编程学习 > asp >>

.net(从控制台读入两个数,实现加减乘除)

[csharp] 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
 
namespace TestClaclulate 

    class Program 
    { 
        static void Main(string[] args) 
        { 
            // 1,定义double变量 
            double numberOne; 
            double numberTwo; 
 
            // 2,从控制台获得两个数 
            try 
            { 
                numberOne = double.Parse(Console.ReadLine()); 
                numberTwo = double.Parse(Console.ReadLine()); 
 
                // 3,输出这两个数的加,减,乘,除 的结果 
                Console.WriteLine(numberOne + " + " + numberTwo + " = " + (numberOne + numberTwo)); 
                Console.WriteLine(numberOne + " - " + numberTwo + " = " + (numberOne - numberTwo)); 
                Console.WriteLine(numberOne + " * " + numberTwo + " = " + (numberOne * numberTwo)); 
                Console.WriteLine(numberOne + " / " + numberTwo + " = " + (numberOne / numberTwo)); 
            } 
            catch (System.FormatException e) 
            { 
                Console.WriteLine(e.Message); 
            } 
 
            // 
            Console.ReadKey(); 
        } 
    } 

作者:haifengzhilian
补充:Web开发 , ASP.Net ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,