從鍵盤輸入兩個數,將其相加並輸出
[csharp]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text
namespace abc
{
class Program
{
static void Main(string[] args)
{
(new Program()).run();
}
public void run()
{
double left=readdouble("輸入左操作數: ");
double right=readdouble("輸入右操作數: ");
writefree(solve(left,right));
}
private void writefree(double p)
{
Console.WriteLine("結果是:{0}", p);
}
private double solve(double left, double right)
{
return left * right;
}
private double readdouble(string p)
{
Console.Write(p);
string Line = Console.ReadLine();
return double.Parse(Line);
}
}
}
附個截圖