以表格的形式輸出5筆購物金額及總金額1.創(chuàng)建一個長度為5的 double類型數(shù)組,存儲購物金額。2.循環(huán)輸入五筆購物金額, 并累加總金額。3.利用循環(huán)輸出五筆購物金額,最后輸出總金額。
try
{
Console.WriteLine("請輸入會員本月的消費記錄:");
string[] money = new string[5];
for (int i = 0; i < money.Length; i++)
{
Console.WriteLine ("請輸入第{0}個購物金額:",i+1);
money[i] =(i+1 +" " + Console .ReadLine ());
}
? ? ? ? Console.WriteLine ("序號? ? ? ? ? ? ? 金額(元)");
? ? ? ? foreach (var item in money)
? ? ? ? {
? ? ? ? ? ? Console.WriteLine(item);
? ? ? ? }
? ? }
? ? catch
? ? { Console.WriteLine ("程序錯誤");
? ? }
? ? Console.ReadKey();