算题

sxblenovo 2010-08-09 06:08:28
如用支付宝在淘宝上购物,一件物品的支付价格为98元,其中支付手续费率为
0.3%(收取卖方),一次购买4件,如要求其中一件物品要求退货,请总结出支付与退款的算法,并做出结果。
备注:1,所有金额保留小数点后两位小数,四舍五入。
2,可连续多次退货。
3,退款时,支付宝也会退回相应手续费
...全文
152 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
萤火架构 2010-08-09
  • 打赏
  • 举报
回复
//支付
public void OrderPay(decimal unitPrice,int amount){
decimal totalPrice = unitPrice*amount;
decimal handlingFee = totalPrice*0.3;
decimal actuallyPay = totalPrice-handlingFee;
//添加数据
}

//退款
public void Reimburse(int OrderID,int amount){
//获取订单数据
OrderInfo objOrder=GetOrder(OrderID);
decimal reduceMoney = objOrder.unitPrice*amount;
decimal reduceHandlingFee=reduceMoney*0.3;
objOrder.actuallyPay = objOrder.actuallyPay - reduceMoney + reduceHandlingFee;
//更新数据
}
Peter200694013 2010-08-09
  • 打赏
  • 举报
回复
买n件 退货m (m <= n) 单价: p

买方支付: (n - m) * p
手续费: (n - m) * p * 0.3%
卖方收: (n - m) * p * 99.7%


int n = 4;
int m = 0;
double p = 98;

double payoff = 0; //买方支付
double expay = 0; //手续费
double rece = 0 ; //卖方收

Console.WriteLine("已经选购{0}件",n);
while (true)
{
Console.WriteLine("输入退货数量:(输入Q or q退出)");
int i = 0;
String str = Console.ReadLine().Trim();
if (str == "Q" || str.ToUpper() == "Q")
break;

if (!Int32.TryParse(str, out i))
continue;
else
{
m += i;
if (m == n)
{
Console.WriteLine("已经全部退货");
break;
}

if (m > n)
{
Console.WriteLine("退货数量大于已购数量");
continue;
}
}
}
payoff = n * p;
expay = (n - m) * p * 0.003;
rece = (n - m) * p * 0.997;

Console.WriteLine("买方支付: " + payoff.ToString("0.00"));
Console.WriteLine("手续费: " + expay.ToString("0.00"));
Console.WriteLine("卖方收: " + rece.ToString("0.00"));
studentliudong 2010-08-09
  • 打赏
  • 举报
回复
题目都看的不是很清楚啊

111,119

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧