美国所得税计算器的Go语言实现
1. 程序基础:输入与应税收入计算
在开始计算所得税之前,我们需要获取用户的总收入和受抚养人数量,进而计算出应税收入。以下是实现该功能的Go代码:
func main() {
// 询问用户2020年W - 2表中的总收入
fmt.Print("Enter your gross income from your W - 2 for 2020:")
var grossIncome float64
fmt.Scanln(&grossIncome) // 从用户处获取总收入输入
fmt.Print("Your gross income is: ")
fmt.Println(grossIncome)
fmt.Print("How many dependents are you claiming? ")
var numDep int
fmt.Scanln(&numDep) // 从用户处获取受抚养人数量输入
fmt.Print("Your claimed number of dependents is: ")
fmt.Println(numDep)
// 计算应税收入
var taxableIncome float64
taxableIncome = grossIncome - 12200 - (2000 * float64(numDep))
fmt.Print("Your taxable income is: ")
fmt.Println(taxableIncome)
}
</
超级会员免费看
订阅专栏 解锁全文

47

被折叠的 条评论
为什么被折叠?



