A_quantity = 10
B_quantity = 20
数量
N = float (input('please enter the quantity of package: '))
X_total = float (N*99.00)
来自输入的费用
Q_discount = (0.2*X_total)
W_discount = (X_total*0.3)
输入总额的折扣
Y_total = (X_total-Q_discount)
M_total = (X_total-W_discount)
带折扣的费用
def main ():
if N >= A_quantity:
print ('the total cost is $', \
format (Y_total, ',.2f'))
else:
if N >= B_ quantity:
print ('the total cost is $', \
format (M_total, ',.2f'))
main ()
结果应为10包$ 792.00
和20个套餐,价格为1,380.00美元
然而第二个声明获得了20%的折扣,总价值为1549.00美元,当它只能获得30%的折扣
答案 0 :(得分:0)
我不知道它是哪种语言,但它是一个算法问题:你应该首先尝试最高值导致它现在设计的方式,如果N = 30,你将总是输入“if”,永远不会“其他”,如果N = 5,你将输入“else”,但是if里面是......
让我试试,虽然我不懂语言:
def main ():
if N >= B_quantity:
print ('the total cost is $', \
format (M_total, ',.2f'))
else:
if N >= A_quantity:
print ('the total cost is $', \
format (Y_total, ',.2f'))
main ()
答案 1 :(得分:0)
将产品的价值除以100并乘以折扣
然后得到这个结果和产品subitrair的值
var SomaPercent = ValorUnit/100 * descont;
var result_fim = ValorUnit-SomaPercent;
答案 2 :(得分:0)
您可以将 if 条件更改为
如果N> = A_quantity&& N< B_quantity ......
如果N> = B_quantity
...