欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-04-20 16:17:33
[csharp]  using system;  using system.collections.generic;  using system.linq; ...
[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