[英]C# Tuition Discount How to compute discount
Example if Tuition Fee is : 3000例如,如果学费是:3000
Discount Percent in Cash : 20% Installment : 5%现金折扣 : 20% 分期付款 : 5%
Total : (here)总计:(这里)
Code代码
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();
Seperate the two discounts into seperate variables and compute to get the right results:将两个折扣分离为单独的变量并计算以获得正确的结果:
//Computation
var cashDiscount = tuition * (cash / 100);
var installationDiscount = tuition * installment;
discount = cashDiscount + installationDiscount;
total = tuition - discount;
textBox5.Text = discount.ToString();
textBox3.Text = total.ToString();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.