Uploaded by Yasir Ahsan

pusedo code2

advertisement
Name = input(nput("What is employees's first and last name? "
if len(fullname.split()) != 2:
print("Please enter valid first and last name separated by space")
sys.exit()
def floatmake(x): # if there are more than 1 decimal or is not a digit the program exit
if x.count('.') > 1:
print('There are to many decimals')
sys.exit()
elif not x.replace('.', '').isdigit():
print('Please eneter a valid number.')
sys.exit()
else:
return eval(x)
def main():
hours = floatmake(input(f'How many hours did {fullname} worked this week? '))
if hours <= 0: # if hours is less or equal to 0 then program exit
print('This value must be greater than zero')
sys.exit()
else:
if hours >= 80:
sys.exit(print('Hours worked must be less than 80 hours'))
hourlyrate = floatmake(input(f'What is {fullname} hourly pay rate? '))
gross_pay = hours * hourlyrate
fica = .062 * gross_pay
married = .12 * gross_pay
single = .10 * gross_pay
fedtax = input(f'Enter federal tax witholding rate S for single and M for married:)').capitalize()
statetax = floatmake(input('Enter state tax witholdings rate:').capitalize())
if fedtax.startswith('M'):
fedtax = married
elif fedtax.startswith('S'):
fedtax = single
statetax_withoutdescimal = (statetax / 100) * gross_pay
statetax_withdecimal = statetax * gross_pay
if statetax > 1:
# if statetax is more than 1 then divide the number by 100 then * by gross
pay
statetax = statetax_withoutdescimal
elif statetax <= 1: # if statetax is less then multiply that number by gross pay
statetax = statetax_withdecimal
try:
num1, num2 = eval(input('Enter two numbers to evaluate '))
if num1 > num2:
print(f'{num1} is greater than {num2}')
if num2 > num1:
print(f'{num2} is larger than {num1}')
print(f'{num1} plus {num2} is {num1 + num2}')
print(f'The absolute difference between {num1} and {num2} is {max(num1,num2)min(num1,num2)}')
print(f'{num1} times {num2} is {num1*num2}')
print(f'{num1} divided by {num2} is {(num1/num2):,.1f} but {num2} divided by {num1} is
{(num2/num1):,.1f}')
if (num1) % (num2) == 0:
print(f'{min(num1,num2)} is a factor of {max(num1,num2)}')
else:
if not (num1) % (num2) == 0:
print(f'{min(num1,num2)} is not factor of {max(num1,num2)}')
except TypeError:
print('You made a type error')
except ZeroDivisionError:
print('Number can not be a zero')
except:
print('A general error')
Download