Ranee G.
asked 05/04/21use Object-Oriented programming concepts to design and implement a system in python for building a scientific calculator which inherits its basic operations from a standard calculator
You are expected to use python Object-Oriented programming concepts to design and implement a system in python for building a scientific calculator which inherits its basic operations from a standard calculator.
1. The standard calculator can perform two types of operations: addition and subtraction.
2. The standard calculator is capable of inputting only two integers. But the scientific calculators can also interpret decimal values.
3. The scientific calculator is capable of four operations: addition, subtraction, cosine, and sine of values.
4. The scientific calculator can accept multiple values for the addition operation.
Hints:
Classes, class variables, objects, methods, constructors, message passing, object arrays, method overloading, method overriding
1 Expert Answer

Patrick B. answered 05/05/21
Math and computer tutor/teacher
import math
class StandardCalculator:
def Add(self,x,y):
return x+y
def Subtract(self,x,y):
return x-y
#####################################
class ScientificCalculator(StandardCalculator):
def Add(self,xNums):
sum=0
N = len(xNums)
for i in range(N):
sum = sum + xNums[i]
return(sum)
def Sin(self,x):
return math.sin(x)
def Cos(self,x):
return math.cos(x)
###################################################
class SuperCalculator(ScientificCalculator):
def Negate(self,x):
return(Subtract(0,x))
def Multiply(self,x,y):
sum=0
for i in range(y):
sum = sum +x
return(sum)
def Reciprocal(self,x):
if x==0:
print("Division By Zero")
else:
return(1/x)
def Divide(self,x,y):
if (y==0):
print("Division By Zero ")
else:
return(x * self.Reciprocal(y))
###########################################
x=[12.5,3.142,2.723,7.05,7.24,7.53,7.25,3.33,-10]
superCalc = SuperCalculator()
print(superCalc.Add(x))
print(superCalc.Subtract(17,9))
print(superCalc.Sin(3.142/6))
print(superCalc.Cos(3.142/6))
print(superCalc.Multiply(4,6))
print(superCalc.Divide(15,5))
print(superCalc.Divide(3,0))
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Ranee G.
Using python OOP concept05/04/21