如何计算学费折扣

本文关键字:计算 何计算 | 更新日期: 2023-09-27 18:13:21

学费为:3000

现金贴现率:20%分期付款:5%

Total:(此处)

int tuition = 0; 
double cash = 0.20; 
double installment = 0.5; 
double discount; double total;
tuition = int.Parse(textBox4.Text); 
cash = double.Parse(textBox1.Text); 
//Computation
discount = tuition * (cash / 100); 
discount = tuition * installment; 
total = tuition - discount; 
textBox5.Text = discount.ToString(); 
textBox3.Text = total.ToString();

如何计算学费折扣

将两个折扣分离为单独的变量并计算以获得正确的结果:

//Computation
var cashDiscount = tuition * (cash / 100); 
var installationDiscount = tuition * installment; 
discount = cashDiscount + installationDiscount;
total = tuition - discount; 
textBox5.Text = discount.ToString(); 
textBox3.Text = total.ToString();