.net(从控制台读入两个数,实现加减乘除)
程序员文章站
2024-01-25 08:54:58
[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