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,...
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++
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.
Assignment: Write an interactive C++·program to determine a type of a triangle based on three sides....
Assignment: Write an interactive C++·program to determine a type of a triangle based on three sides. Have a user input 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...
Write a program to calculate the area and circumference of a cuboid. Use printf to display...
Write a program to calculate the area and circumference of a cuboid. Use printf to display 2 digits after decimal point in all the results Program should be in java language.
Write a C program with the following prompt *do not use gotostatement* "Write an interactive...
Write a C program with the following prompt *do not use goto statement* "Write an interactive program that implements a simple calculator. The program should allow the user to choose a binary arithmetic operation and enter two terms to which to apply the operation. The program should then compute the result and display it to the user. Your calculator will have two modes: double-precision mode and integer mode. Double-precision mode will do calculations and output using variables of type double....
Write a program to calculate the area of four shapes (Rectangle, triangle, circle and square). The...
Write a program to calculate the area of four shapes (Rectangle, triangle, circle and square). The program to present the user with a menu where one of the shapes can be selected. Based on the selection made, the user enters the proper input, the program validates the input (i.e all entries must be greater than zero). Once the input is entered and validated, the intended area is calculated and the entered information along with the area are displayed. Area of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT