有问题写一个数学方程式

时间:2013-09-05 23:33:12

标签: c# visual-studio-2010 formulas

坚持如何执行如下的简单线公式:

double profit=0;
double totalPrice=19.25;
int cost = 12;

profit = totalPrice - 2.15(totalPrice * 15 %) - (cost);

如何在代码中编写上述等式我从未在2.1515%上给出错误之前完成。我如何表示这些数字?

谢谢

2 个答案:

答案 0 :(得分:3)

profit = totalPrice - (2.15 * (totalPrice * .15)) - cost;

答案 1 :(得分:3)

profit = totalPrice - 2.15 * (totalPrice * 0.15) - (cost);

15%表示为0.15。