-5

目前,我为在我的网上商店购买多件商品提供固定折扣。因此,例如,买方可能会获得 100 美元总价的 25 美元的折扣 - 所以最终他将支付 75 美元。支付交易卡中间商现在要我为买家购买的每件商品添加折扣。因此,如果他购买以下 2 顶帽子: 25 美元,每把 1 把雨伞:20 美元 1 件 T 恤:30 美元,那么我如何减去我通常从购买中的每件商品的总价中减去的正确折扣?

如果有人可以帮助我在 c# 中为此编写一个算法,那就太好了

提前致谢

4

1 回答 1

1

What is the current code you have? A C# example would look something like this:

// Assuming 'items' is an Enumerable type containing the list of items in the order var totalCost = 0; for (var i in items) { // Accumulates the cost of each item at a 25% discount totalCost += 0.75 * i.Cost; }

于 2018-07-14T22:41:43.700 回答