看板 C_Sharp 關於我們 聯絡資訊
不知道可以在這裡發問嗎? 如果不適合的話就請提省 我會自D 或是版大幫忙一下了... 這是一支簡單要算所得稅的程式 現在問題是不知道要宣告變數tax為什麼類型... 我只知道 string tax = ""; (是這樣寫) double tax = ; ︿︿︿︿︿︿︿? 現在就是這行不知道後面要填啥.... 請知道的高手回答一下好嗎... 很蠢的新手問題...感謝~ 這是整隻程式... Console.Write("請輸入淨所得:"); string i = Console.ReadLine(); int income = int.Parse(i); if (income <= 300000) tax = income*0.06; else if (income <= 800000) tax = (income-300000)*0.13+30000*0.06; else if (income <= 2000000) tax = (income-1100000)*0.21+500000*0.13+300000*0.06; else if (income > 2000000) tax = (income-2000000)*0.3+900000*0.21+500000*0.13+300000*0.06; Console.WriteLine("您的所得稅為:{0}",tax); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.7.59
kikolee:做個初始化的動作就好,ex: double tax=0.0; 03/27 16:59
tomex:關於錢的,建議都宣告成decimal型別,避免不夠的麻煩. 03/29 23:32