私の新しいループは私の新しい販売手数料プログラムを更新していませんeveerytime私はプログラムを実行します。ここでwhileループを使用した販売手数料プログラム。値は更新されません
#this program calculates sales commissions and sums the total of all sales commissions the user has entered
print("Welcom to the program sales commission loop")
keep_going='y'
while keep_going=='y':
#get a salespersons sales and commission rate
sales=float(input('Enter the amount of sales'))
comm_rate=float(input('Enter commission rate'))
total=0
#calculate the commission
commission=sales*comm_rate
print("commission is",commission)
keep_going=input('Enter y for yes')
total=total+commission
print("Total is",total)
print("You have exited the program. Thet total is",total)
プログラムの出力はされています:ここに私のプログラムがあるのPython 3.5.2(v3.5.2:4def2a2901a5、2016年6月25日、22時01分18秒)[MSC v.1900 32ビット(インテル)] on win32 詳細については、「copyright」、「credits」または「license()」と入力してください。
Welcom to the program sales commission loop
Enter the amount of sales899
Enter commission rate.09
commission is 80.91
Enter y for yesy
Total is 80.91
Enter the amount of sales933
Enter commission rate.04
commission is 37.32
Enter y for yesy
Total is 37.32
Enter the amount of sales9909
Enter commission rate.10
commission is 990.9000000000001
Enter y for yesn
Total is 990.9000000000001
You have exited the program. Thet total is 990.9000000000001
>>>
> Blockquote
私が間違って何をしているのですか?私はそれを把握することができません
どこが間違っていると思いますか?実際には明示的ではないので、予想される入出力を書き留めるようにしてください。 – Nishant
を更新していない合計を参照している場合は、各ループの開始時に0に設定しているためです。ループの外側で、total = 0を開始する直前に開始します。 – wbrugato
"keep_going = True"を実行し、その後に "keep_going"を実行することをお勧めします。 "=" y "コードを使用する場合は、" keep_goingの中で '' y ''と答えてください。 – JasonD