Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

If programming a class to represent a geometry calculator, which class containing methods with parameters could be used to calculate the volume of a cube

If programming a class to represent a geometry calculator, which class containing methods with parameters could be used to calculate the volume of a cube with length l, width w and height h; the volume of a cylinder with radius r and height h; and increment the total number of calculations performed?
class Geo_Calc:
def __init__(self):
self.numOfCalcs =0
def clearTotal(self):
self.numOfCalcs =0
def returnTotal(self):
return self.numOfCalcs
def volume_of_cube(self):
numOfCalcs +=1
return l * w * h
def volume_of_cylinder(self):
numOfCalcs +=1
return math.pi * r * r * h
class Geo_Calc:
def __init__(self):
self.numOfCalcs =0
def clearTotal(self):
self.numOfCalcs =0
def returnTotal(self):
return self.numOfCalcs
def volume_of_cube(self,l,w,h):
numOfCalcs +=1
return l * w * h
def volume_of_cylinder(self,r,h):
numOfCalcs +=1
return math.pi * r * r * h
class Geo_Calc:
def __init__(self):
self.numOfCalcs =0
def clearTotal(self):
self.numOfCalcs =0
def returnTotal(self):
return self.numOfCalcs
def volume_of_cube(self,l,w,h):
self.numOfCalcs +=1
return l * w * h
def volume_of_cylinder(self,r,h):
self.numOfCalcs +=1
return math.pi * r * r * h
class Geo_Calc:
def __init__(self):
self.numOfCalcs =0
def clearTotal(self):
self.numOfCalcs =0
def returnTotal(self):
return self.numOfCalcs
def volume_of_cube(self):
self.numOfCalcs +=1
return l * w * h
def volume_of_cylinder(self):
self.numOfCalcs +=1
return math.pi * r * r * h

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions