EXERCISE :2 FAULTY CALCULATOR
#EXERCISE 2
# 45 * 3 = 555, 56+9 = 77, 56/6 = 4
#DESIGN A CALCULATOR WHICH WILL CORRECTLY SOLVE ALL THE PROBLEM EXCEPT THE FOLLOWING ONE:
#45 * 3 = 555, 56+9 = 77, 56/6 = 4
#YOUR PROGRAM SHOULD TAKE OPERATOR AND TWO NUMBER AS INPUT FROM THE USER AND THEN RETURN THE RESULT
print ("calculator \n please choose an operator \n + for addition \n - for substraction \n * for multiplication \n / for division")
a = (input("please choose an operator"))
b = int(input("enter first number"))
c = int(input("enter second number"))
if b ==45 and c ==3 and a =='*':
print ("555")
elif b ==56 and c ==9 and a =='+':
print ("77")
elif b ==56 and c ==6 and a =='/':
print ("4")
elif a =='*':
multiply=b*c
print (multiply)
elif a =='+':
add=b+c
print (add)
elif a =='/':
division=b*c
print (division)
else:
print ("error! please check your input")
Comments
Post a Comment