111,119
社区成员
发帖
与我相关
我的任务
分享
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"));