-2
# ABC Inc., Gross Pay Calculator!
# Enter employee's name or 0 to quit : Nathan
# Enter hours worked : 35
# Enter employee's pay rate : 10.00
# Employee Name : Nathan
# Gross Pay: 350.0
# Enter next employee's name or 0 to quit : Toby
# Enter hours worked : 45
# Enter employee's pay rate : 10
# Employee Name : Toby
# Gross Pay : 475.0
# (overtime pay : 75.0)
# Enter next employee's name or 0 to quit : 0
# Exiting program...
「プログラムを終了しています」という出力を0にして終了するにはどうすればよいですか?0を入力してプログラムを終了させるにはどうすればいいですか?
print('ABC inc., Gross Pay Calculator!')
name = input("Enter employee's name or 0 to quit:")
hours = float(input("Enter hours worked:"))
payrate = float(input("Enter employee's pay rate:"))
print("Employee Name:", name)
grosspay = hours * payrate
print("Gross pay:", grosspay)
if hours > 40:
print("(Overtime pay:", (hours - 40) * payrate * 1.5)
while name!=0:
name = input("Enter next employee's name or 0 to quit:")
hours = float(input("Enter hours worked:"))
payrate = float(input("Enter employee's pay rate:"))
print("Employee Name:", name)
grosspay = hours * payrate
print("Gross pay:", grosspay)
if hours > 40:
print("(Overtime pay:", (hours - 40) * payrate*1.5)
else:
print ('Exiting program...')
'while name!=" 0 "'。 'input'は文字列を返します。 –
[入力をPythonで整数として読み取るにはどうすればいいですか?](http://stackoverflow.com/questions/20449427/how-can-i-read-inputs-as-integers-in-python) –