總網頁瀏覽量

2011年11月1日 星期二

[VB.NET] 使用 Math.Round 做四捨五入


'Math.Round 做四捨五入
Sub Main()
    Dim x, y, z As Integer
    Console.WriteLine("  成績計算系統   ")
    Console.WriteLine("=================")
    Console.Write("輸入第一次成績:") : x = Console.ReadLine()
    Console.Write("輸入第二次成績:") : y = Console.ReadLine()
    Console.Write("輸入第三次成績:") : z = Console.ReadLine()
    Console.WriteLine("=================")
    Console.WriteLine("平均成績 = {0}", Math.Round((x + y + z) / 3, 2))
    Console.Read()
End Sub

沒有留言:

張貼留言