
USE PYTHON
Write a Python Cylinder class to get the desired output as shown below.
1. You will have to create a Cylinder class.
2. You will have to create 2 class variables.
3. Create a required constructor.
4. Write 2 class methods:
• One that takes the height first and then the radius and then swaps
• One that takes a string where the radius and height values are separated
with a hyphen.
Write 2 static methods:
• One that calculates the area of a whole cylinder (formula: 2πr^2 + 2πrh)
• Another that calculates the volume of a cylinder (formula: πr^2h)
**Observe the output values carefully to understand how the radius and height values are changing.
[You are not allowed to change the code below]
#Write your code here
c1 = Cylinder(0,0)
Cylinder.area(c1.radius,c1.height)
Cylinder.volume(c1.radius,c1.height)
print("===============================")
c2 = Cylinder.swap(8,3)
c2.area(c2.radius,c2.height)
c2.volume(c2.radius,c2.height)
print("===============================")
c3 = Cylinder.changeFormat("7-13")
c3.area(c3.radius,c3.height)
c3.volume(c3.radius,c3.height)
print("===============================")
Cylinder(0.3,5.56).area(Cylinder.radius,Cylinder.height)
print("===============================")
Cylinder(3,5).volume(Cylinder.radius,Cylinder.height))
Output:
Default radius=5 and height=18.
Updated: radius=0 and height=0.
Area: 0.0
Volume: 0.0
===============================
Default radius=0 and height=0.
Updated: radius=3 and height=8.
Area: 207.34511513692635
Volume: 226.1946710584651
===============================
Default radius=3 and height=8.
Updated: radius=7.0 and height=13.0.
Area: 879.645943005142
Volume: 2001.1945203366981
===============================
Default radius=7.0 and height=13.0.
Updated: radius=0.3 and height=5.56.
Area: 11.045839770021713
===============================
Default radius=0.3 and height=5.56.
Updated: radius=3 and height=5.
Volume: 141.3716694115407
![Write a Cylinder class to get the desired output as shown below.
1. You will have to create a Cylinder class.
2. You will have to create 2 class variables.
3. Create a required constructor.
4. Write 2 class methods:
• One that takes the height first and then the radius and then swaps
• One that takes a string where the radius and height values are separated
with a hyphen.
Write 2 static methods:
• One that calculates the area of a whole cylinder (formula: 2mr + 2rh)
• Another that calculates the volume of a cylinder (formula: h)
**Observe the output values carefully to understand how the radius and height values
are changing.
|You are not allowed to change the code below]
# Write your code here
Output:
Default radius=5 and height=18.
Updated: radius=0 and height=0.
Area: 0.0
Volume: 0.0
c1 = Cylinder(0,0)
Cylinder.area(c1.radius,c1.height)
Cylinder.volume(c1.radius,c1.height)
print("====
c2 = Cylinder.swap(8,3)
c2.area(c2.radius,c2.height)
c2.volume(c2.radius.c2.height)
print("=========
c3 = Cylinder.changeFormat("7-13")
c3.area(c3.radius.c3.height)
c3.volume(c3.radius.c3.height)
print("====
Cylinder(0.3,5.56).area(Cylinder.radius,Cylinder.height) Default radius=7.0 and height=13.0.
print("=====
Cylinder(3,5).volume(Cylinder.radius,Cylinder.height)) Area: 11.045839770021713
Default radius=0 and height=0.
Updated: radius=3 and height=8.
Area: 207.34511513692635
Volume: 226.1946710584651
===--===")
==================m:
====
Default radius=3 and height=8.
Updated: radius=7.0 and height=13.0.
Area: 879.645943005142
Volume: 2001.1945203366981
=========")
=========")
Updated: radius-0.3 and height=5.56.
=====
Default radius=0.3 and height=5.56.
Updated: radius=3 and height=5.
Volume: 141.3716694115407](https://content.bartleby.com/qna-images/question/84082150-1ceb-4545-95d4-8ee66aa6d63e/58f47633-a585-43bc-98ce-0ff82913fe2b/qbm67e_thumbnail.jpeg)

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images

- Write java code for a calculator that calculates the Sum and Product of 2 numbers Program requirements: 1. Documentation 2. Write a method named userinput that asks users to input 2 integer numbers. >>Hint: Method with no parameters that returns 2 values. 3. Write a method named Calculator that calculates the Sum and Product of 2 numbers ->Hint: Method with 2 parameters that returns 2 values. 4. Write a method name Display that displays the Sum and Product of the 2 numbers >>Hint: Method with 2 parameters and no returns (void). 5. Use a do-while loop and ask the user to continue or not. 6. Your program output format must be exactly the following: ->Note: Include the output in your program. =>> Calculator Enter the first number: 100 Enter the second number: 200 Sum = 300 Product = 20000 Enter any number to continue or 0 to exit: 8 =>> Calculator Enter the first number: 6 Enter the second number: 9 Sum = 15 Product = 54 Enter any number to continue or 0 to exit: 0 ++++ End of the program…arrow_forwardJAVA Write a public static method named getMaxOf2Ints that takes in 2 int arguments and returns the Maximum of the 2 values Write a public static method named getMinOf2Ints that takes in 2 int arguments and returns the Minimum of the 2 values Write a public static method named getMaxOf3Ints that takes in 3 int arguments and returns the Maximum of the 3 values Write a public static method named getMedianOf3Ints that takes in 3 int arguments and returns the Median Value of the 3 values Write a public static method named printMinOf3Ints that takes in 3 int arguments of type int and prints the minimum value of those 3 ints Example: “The min is “ + minVal Write a public static method named getProdOfAllPositiveInts that takes in 1 int argument and returns the product of all the values between 1 and that number. If the argument is NON-positive return 0 Write a public static method named getProdOfAllNegativeInts that takes in 1 int argument and returns the product of…arrow_forwardQUESTION 10 Multiple Choice: What is the return type of the following method? public static void widget(double a, String b){ ... } String void int double QUESTION 11 Multiple Choice: Which statement is true about the method below? public static String doStuff(int x, double n, boolean b){ ... } String is the return type of this method int x, doublen, and boolean b will cause a syntax error and should be moved to the method body public and static are identifiers for the method O doStuff is a modifier for the method QUESTION 12arrow_forward
- public class Accumulator { private int total private String name; public Accummulator (string name , int total) { this .name = name; this .total=total; } } 3. In a main method, create an object of Accumulator with the name as "Mary" and total as 100.arrow_forwardChoose the correct answer: You can pass in multiple parameters with different data types into a method. You can pass in only parameters with the same data type into a method. You can receive multiple return values from a method. You can receive a return value with multiple data types from a method.arrow_forward#this is a python program #topic: OOP Design the Country class so that the code gives the expected output. [You are not allowed to change the code below] # Write your Class Code here country = Country() print('Name:',country.name) print('Continent:',country.continent) print('Capital:',country.capital) print('Fifa Ranking:',country.fifa_ranking) print('===================') country.name = “Belgium” country.continent = “Europe” country.capital = “Brussels” country.fifa_ranking = 1 print('Name:',country.name) print('Continent:',country.continent) print('Capital:',country.capital) print('Fifa Ranking:',country.fifa_ranking) Output: Name: Bangladesh Continent: Asia Capital: Dhaka Fifa Ranking: 187 =================== Name: Belgium Continent: Europe Capital: Brussels Fifa Ranking: 1arrow_forward
- In python and include doctring: First, write a class named Movie that has four data members: title, genre, director, and year. It should have: an init method that takes as arguments the title, genre, director, and year (in that order) and assigns them to the data members. The year is an integer and the others are strings. get methods for each of the data members (get_title, get_genre, get_director, and get_year). Next write a class named StreamingService that has two data members: name and catalog. the catalog is a dictionary of Movies, with the titles as the keys and the Movie objects as the corresponding values (you can assume there aren't any Movies with the same title). The StreamingService class should have: an init method that takes the name as an argument, and assigns it to the name data member. The catalog data member should be initialized to an empty dictionary. get methods for each of the data members (get_name and get_catalog). a method named add_movie that takes a Movie…arrow_forwardstatic methods/variable vs. dynamic methods/variable Please describe static methods & static variables. Also describe when you might want to use static methods and static variables. Please write down the example code snippets where the static methods and static variables are good fit for.arrow_forwardQuestion Two Write a java program that prints student's name, grades and GPA. You must do the following requirements: 1. Create three methods: a. First method to accept and print your first, last name, and GPA. 2. Call the three methods you created above in your main method. b. Second method Markt and print your grades Marks of three courses (type: int) 3. Create a method without parameters that would return only your GPA. The method should be named with your last name followed by GPA (e.g., AlwalledGPA()). Note: c. Third method to overload the second method (types: double). The method must print your grades. 4. Declare a double variable that holds the returned value of the last method you created. 5. Print the value of your GPA variable. Help ● The class name of your Java program must be your first name. • Your answer should have the code as text as well as the screenshot of the program output (using your own name) as a part of your answer. Otherwise, zero marks will be awarded.…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





