Question

In: Computer Science

Part One: Write an interactive program to calculate the volume and surface area of a three-dimensional...

Part One: Write an interactive program to calculate the volume and surface area of a three-dimensional object. Use the following guidelines to write your program:

  1. Create a word problem that involves calculating the volume and surface area of a three-dimensional object. Choose one of the following:
    • Cube: surface area 6 s2 , volume s3
    • Sphere: surface area 4πr2 , volume (4.0/3.0) π r3
    • Cylinder: surface area 2π r2 + 2 π r h, volume π r2 h
    • Cone: surface area πr(r+√(h2+r2) ), volume 1.0/3.0 π r2 h
  2. Print the description of the word problem for the user to read.
  3. Ask the user to enter the information necessary to perform the calculations.
  4. Use 3.14 for the value of π as needed.
  5. Print the results of each calculation.
  6. Write the pseudocode for this program. Be sure to include the needed input, calculations, and output.

Part Two: Code the program. Use the following guidelines to code your program.

  1. To code the program, use the Python IDLE.
  2. Using comments, type a heading that includes your name, today’s date, and a short description of the program.
  3. Follow the Python style conventions regarding indentation and the use of white space in your program.
  4. Use meaningful names for all variables.

Solutions

Expert Solution

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks

#code

# value for pi
pi = 3.14


def surfaceArea(radius, height):
    '''
    this method calculates the surface area of a cylinder with
    given radius and height
    '''
   
area = (2 * pi * radius * radius) + (2 * pi * radius * height)
    return area


def volume(radius, height):
    '''
        this method calculates the volume of a cylinder with
        given radius and height
    '''
   
vol = pi * radius * radius * height
    return vol


def main():
    # printing description
   
print('THIS PROGRAM CALCULATE THE SURFACE AREA & VOLUME OF A CYLINDER')
    # print your name and other details here.

    # getting radius and height from user
   
radius = float(input('Enter the radius: '))
    height = float(input('Enter the height: '))
    # finding and displaying area and volume
   
area = surfaceArea(radius, height)
    vol = volume(radius, height)
    print('The surface area is:', area)
    print('The volume is:', vol)



# calling main()
main()

#output

THIS PROGRAM CALCULATE THE SURFACE AREA & VOLUME OF A CYLINDER

Enter the radius: 25

Enter the height: 60

The surface area is: 13345.0

The volume is: 117750.0

#pseudocode (plain english)

1. Initialize Pi to 3.14

2. Read radius, height

3. Set area = (2 * pi * radius * radius) + (2 * pi * radius * height)

4. Set volume = pi * radius * radius * height

5. Display area, volume

6. Quit


Related Solutions

1) Write a functional program in Java that can calculate the volume and surface area of...
1) Write a functional program in Java that can calculate the volume and surface area of a sphere and a cube 2) Write a procedural program in Java that can calculate the volume and surface area of a sphere and a cube 3) Write an Object Oriented Program in Java that can find the volume and surface area of a sphere and cube
Write a C++ program to calculate the sphere volume and surface area. Provided that the sphere...
Write a C++ program to calculate the sphere volume and surface area. Provided that the sphere volume = and the sphere surface area = , where r is the radius. 1. Read r from the user using cin statement. 2. Calculate the volume (Vol) and the surface area (Area) of a sphere. 3. Print r, Vol, and Area in a suitable messages.
Write a program in C++ that solves this problem Calculate the area and volume of a...
Write a program in C++ that solves this problem Calculate the area and volume of a sphere problem. Inside a for loop, vary the radius from 10 to 40  with a step or increment of 5 and calculate the area and volume Your radius will be equal to your loop counter. All calculations should have 2 decimal places, but the radius should have zero decimal places and any number of 1,000 or more should have a comma. Print the radius, area,...
Write a C++ program for the following problem: Calculate and print the area and volume of...
Write a C++ program for the following problem: Calculate and print the area and volume of a cone inside a While  loop that goes from 1 to 20 with a step of .5. (the step is 1/2 or Point 5, so you go 10, 10.5,11, 11.5) Note: Your loop variable will need to be a double data type Use two decimal places on all numbers that are double data type. This will be a table with 3 columns. Don't worry about...
Write most basic C++ program possible that calculates volume and surface area of five shapes (Cube,...
Write most basic C++ program possible that calculates volume and surface area of five shapes (Cube, Sphere, Prism, Cylinder, Cone), where each shape has its own class (with a volume function, surface area function, constructor, as well as get and set functions), and the shape dimensions are private class members. Include input and display functions.
know the mathematical relationship between surface area and volume, and explain how surface to area volume...
know the mathematical relationship between surface area and volume, and explain how surface to area volume affects heat loss. Which can be smaller endotherms or ectotherms  
Write a program that reads the radius of a sphere and calculates it's volume and surface...
Write a program that reads the radius of a sphere and calculates it's volume and surface area. Format results to 4 decimal places. The radius=3.2 Your program should output volume and surface area.  Repeat same steps for program2, but this time use the following input values: a= ꟷ2.4 , b = 4.5 . Your program should output sum, Fun1, and Fun2. It's for C++
You are required to write an interactive JS program that prompts the user for three numbers...
You are required to write an interactive JS program that prompts the user for three numbers and then finds the sum, average, smallest, and the largest value of the numbers and prints the results labeling properly.
Write an interactive C++·program to have a user input their three initials and the length of...
Write an interactive C++·program to have a user input their three initials and the length of three sides of a triangle. Allow the user to enter the sides in any order. Determine if the entered sides form a valid triangle.The triangle may not have negative sides.The sum of any two sides must be greater than the third side to form a triangle. Determine if the entered sides are part of a scalene, isosceles, or equilateral triangle. Using the Pythagorean Theorem,...
Write a JavaScript function to calculate the surface area of a sphere. Input the radius using...
Write a JavaScript function to calculate the surface area of a sphere. Input the radius using a NumericUpDown. Have the function calculate the surface area and display it on your page. Label the inputs and the output on your page. Change the title to "Oh, Boy! JavaScript!". Put your name at the top in camelCase. Put your major at the bottom in camelCase.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT