Home [C# 筆記] 循序結構(Sequence Structure)
Post
Cancel

[C# 筆記] 循序結構(Sequence Structure)

「 循序結構(Sequence Structure)」顧名思義就是指「在程式流程中,依照先後順序由上而下,一行一行執行下來逐一完成」。

範例

設計一個簡單的計算95無鉛汽油油價程式,當使用者輸入公升數時,計算出所需支付的金額。

1
2
3
4
5
double litre, oilPrice; //宣告公升、所需支付油價的變數(double型別)
litre = double.Parse(Console.ReadLine()!); //將使用者輸入轉換為double
oilPrice = litre * 28.6; //計算所需支付的金額

Console.WriteLine($"共需 ${oilPrice}元"); //輸出結果

Book: Visual C# 2005 建構資訊系統實戰經典教本

This post is licensed under CC BY 4.0 by the author.