.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
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
上一篇: 现在打流感疫苗还来得及吗
下一篇: 小儿腹泻早期有哪些常见症状