Python Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science
3rd Edition
ISBN: 9781590282779
Author: John Zelle
Publisher: Franklin Beedle & Associates
Question
Book Icon
Chapter 10, Problem 9PE
Program Plan Intro

Sphere

Program Plan:

Sphere.py

  • Import the required packages.
  • Definition of main method
    • Get the radius of the sphere
    • Call the method “Sphere()” by passing the parameter “rad”.
    • Call the method “surfaceArea()”.
    • Call the method “volume()”.
    • Print the volume of the sphere
    • Print the area of the sphere.
  • Call the main function

Main.py:

  • Import the required packages
  • Definition of class sphere
    • Definition of method “init()”.
      • Assign the value of radius.
    • Definition of method “getRadius()”.
      • Return the value of radius.
    • Definition of method “surfaceArea()”.
      • Calculate surface area
    • Definition of method “volume()”.
      • Calculate the volume.
    • Return the volume.

Blurred answer
Students have asked these similar questions
Implement the critter class. Each critter C has attributes species, size, and age. • The constructor accepts arguments for the attributes above, in the order above. You can expect size and age to be numeric values. Each critter C has a can_eat () method, which: Receives one argument, prey, which you can expect to be another Critter object. Compares prey 's size against C's. o If C is larger than prey, return True. Otherwise, return False. Each critter C also has a survive_year () method, which: • Increases C's size and age by 1, respectively, and returns C's current size.
Design an application that does the following: A Solid can be a FlatSurfaceSolid or a CurvedSurfaceSolid. Every solid will have a volume. The method volume will be polymorphic. A solid has faces, vertices and edges. A flat-surface solid also has a variable called side which represents the length of the side. A curved-surface solid also has a radius. A Cube is a FlatSurfaceSolid. A cube has 6 faces, 8 vertices and 12 edges. It will have a side. A Sphere is a CurvedSurfaceSolid. It has 1 face, 0 vertices and 0 edges. It will have a radius. Create an ArrayList of solids (driver file named YourLastNameCISC231Q1.java). The arraylist will have 4 elements – 2 cubes (one with side length 3 and another will side length 4) and 2 spheres (one with radius 3 and another with radius 4). Create a driver class to instantiate an array of solids and display the details of each solid along with the volume of each solid.
JAVA HELP PLEASE! Write a class Rectangle that has only the following public methods (you can add other non-public methods if you think you need them): Write a constructor that creates a rectangle using the x, y coordinates of its lower left corner, its width and its height (the parameters must be in that order). Creating a rectangle with non-positive width or height should not be allowed; throw an IllegalArgumentException for those cases. The values of x and y are allowed to be negative. Write a method overlap(Rectangle other). This method should return true if this rectangle overlaps with other, false otherwise. Rectangles that touch each other are not considered to be overlapping. Write a method toString that returns a String. The string should be formatted exactly as:“x:2, y:3, w:4, h:5”without the quotation marks and replacing the numbers with the actual attribute values of the object. A class called Rectangle exists in Java already. You are not allowed to use this class in any…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education