Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

in python, classes and objects, please 1. Implement a class SodaCan with methods

ID: 3760531 • Letter: I

Question

in python, classes and objects, please

1.Implement a class SodaCan with methods getSurfaceArea() and getVolume(). In the constructor, supply the height and radius of the can.

Surface Area = (2* pi * radius * height) + (2 * pi * radius2)

Volume = pi * radius2 * height

Use the following to run your class:

can = SodaCan (2,4)

print(“The volume of the can is”, can.getVolume())

print(“The surface area of the can is”, can.getSurfaceArea())

#adding a button to tally counter, undoing.

#adding a button to tally counter, undoing.

2.Simulate a tally counter that can be used to admit a limited number of people. First, the limit is set with a cal

def setlimit(self, maximum)

if the count button is clicked more often than the limit, simulate an alarm by printing out a message “Limit exceeded”.

     

Test your program by performing the following:

Reset

Set Limit to 2

2 clicks

Print Value

1 click

Print Value

Explanation / Answer

2)
public class counter
{
private int value;
private int maximum;
public int getValue()
{
return value;
}
public void count()
{
if (value + 1 > maximum)
{
System.out.println("The limit is exceeded");
}
else
{
value = value + 1;
}
}
public void reset()
{
value = 0;
}
public void undo()
{
value -= 1;
}
public void setLimit(int maximum)
{
this.maximum = maximum;
}
}


1)
public class Soda can
{
private double height;
private double radius;
public soda can(double height, double radius)
{
this.height = height;
this.radius = radius;
}
public double getSurface()
{
return 2 * Math.PI * this.radius * this.radius + 2 * Math.PI * this.radius * this.height;
}
public double getVolume()
{
return Math.PI * this.radius * this.radius * 2 * this.height;
}
}