SlideShare a Scribd company logo
1 of 1
Download to read offline
Exercise 2: Implementing Geometry Formulas with functions (10 points) Implement the
following functions that return the volume and surface areas of 3D shapes: double
cone_volume(double r , double h ) ; // r = radius, h = height double cone_surface(double r ,
double h ) ; // r = radius, h = height double cube_volume(double a); // a = edge double
cube_surface(double a) ; // a = edge double sphere_volume(double r ) ; // r = radius double
sphere_surface(double r ) ; // r = radius double cylinder_volume(double r , double h ) ; // r =
radius, h = height double cylinder_surface(double r , double h ) ; // r = radius, h = height Write a
program that prompts the user to enter whether they have a cone, cube, sphere, or cylinder. - If
the user enters "cone", the program then prompts the user to enter two values: radius and height.
The program then calls the respective functions to print the volume and surface area of the cone.
- If the user enters "cube", the program then prompts the user to enter one value: edge length.
The program then calls the respective functions to print the volume and surface area of the cube.
- If the user enters "sphere", the program then prompts the user to enter one value: radius. The
program then calls the respective functions to print the volume and surface area of the sphere. - If
the user enters "cylinder", the program then prompts the user to enter two values: radius and
height. The program then calls the respective functions to print the volume and surface area of a
cylinder. - If the user enters anything other than cone, cube, sphere, or cylinder, print "Invalid
shape."

More Related Content

Similar to Exercise 2- Implementing Geometry Formulas with functions (10 points) (1).pdf

Business App Programming Course Project
Business App Programming Course ProjectBusiness App Programming Course Project
Business App Programming Course Project
Carmen Lampkin
 
Modify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdfModify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdf
hullibergerr25980
 

Similar to Exercise 2- Implementing Geometry Formulas with functions (10 points) (1).pdf (6)

DSA Lesson 2 - Algorithm and Flowcharting.pdf
DSA Lesson 2 - Algorithm and Flowcharting.pdfDSA Lesson 2 - Algorithm and Flowcharting.pdf
DSA Lesson 2 - Algorithm and Flowcharting.pdf
 
Business App Programming Course Project
Business App Programming Course ProjectBusiness App Programming Course Project
Business App Programming Course Project
 
A graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolationA graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolation
 
Modify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdfModify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdf
 
Chapter10.pptx
Chapter10.pptxChapter10.pptx
Chapter10.pptx
 
Application of Derivative Class 12th Best Project by Shubham prasad
Application of Derivative Class 12th Best Project by Shubham prasadApplication of Derivative Class 12th Best Project by Shubham prasad
Application of Derivative Class 12th Best Project by Shubham prasad
 

More from karimshaikh24

Evidence that natural selection does not cause adaptation to match fut.pdf
Evidence that natural selection does not cause adaptation to match fut.pdfEvidence that natural selection does not cause adaptation to match fut.pdf
Evidence that natural selection does not cause adaptation to match fut.pdf
karimshaikh24
 
Estimated Annual Life Insurance Premium Rates per $1-000 of Face Value.pdf
Estimated Annual Life Insurance Premium Rates per $1-000 of Face Value.pdfEstimated Annual Life Insurance Premium Rates per $1-000 of Face Value.pdf
Estimated Annual Life Insurance Premium Rates per $1-000 of Face Value.pdf
karimshaikh24
 

More from karimshaikh24 (20)

Exercise- a growth model with no growth - Suppose the labor force is c.pdf
Exercise- a growth model with no growth - Suppose the labor force is c.pdfExercise- a growth model with no growth - Suppose the labor force is c.pdf
Exercise- a growth model with no growth - Suppose the labor force is c.pdf
 
Exercise 4- Separation of soil constituents by Mechanical Analysis- Ca.pdf
Exercise 4- Separation of soil constituents by Mechanical Analysis- Ca.pdfExercise 4- Separation of soil constituents by Mechanical Analysis- Ca.pdf
Exercise 4- Separation of soil constituents by Mechanical Analysis- Ca.pdf
 
Exercise 4 Suppose that there are now fees associated with foreign exc.pdf
Exercise 4 Suppose that there are now fees associated with foreign exc.pdfExercise 4 Suppose that there are now fees associated with foreign exc.pdf
Exercise 4 Suppose that there are now fees associated with foreign exc.pdf
 
Exercise 3-15-Design and implement aMinQueuedata structure that can st.pdf
Exercise 3-15-Design and implement aMinQueuedata structure that can st.pdfExercise 3-15-Design and implement aMinQueuedata structure that can st.pdf
Exercise 3-15-Design and implement aMinQueuedata structure that can st.pdf
 
Exercise 3 PYTHON Identify the most common words in the description of.pdf
Exercise 3 PYTHON Identify the most common words in the description of.pdfExercise 3 PYTHON Identify the most common words in the description of.pdf
Exercise 3 PYTHON Identify the most common words in the description of.pdf
 
Example 1- A recent study focused on the number of times men and women (1).pdf
Example 1- A recent study focused on the number of times men and women (1).pdfExample 1- A recent study focused on the number of times men and women (1).pdf
Example 1- A recent study focused on the number of times men and women (1).pdf
 
Examine the screenshot provided below- Check only the answers that are.pdf
Examine the screenshot provided below- Check only the answers that are.pdfExamine the screenshot provided below- Check only the answers that are.pdf
Examine the screenshot provided below- Check only the answers that are.pdf
 
Evidence that natural selection does not cause adaptation to match fut.pdf
Evidence that natural selection does not cause adaptation to match fut.pdfEvidence that natural selection does not cause adaptation to match fut.pdf
Evidence that natural selection does not cause adaptation to match fut.pdf
 
exactly 2 - Click on the icon to viens the binomial probabities table-.pdf
exactly 2 - Click on the icon to viens the binomial probabities table-.pdfexactly 2 - Click on the icon to viens the binomial probabities table-.pdf
exactly 2 - Click on the icon to viens the binomial probabities table-.pdf
 
Every year- natural disasters impact families- communities- nations- a.pdf
Every year- natural disasters impact families- communities- nations- a.pdfEvery year- natural disasters impact families- communities- nations- a.pdf
Every year- natural disasters impact families- communities- nations- a.pdf
 
Event A occurs with probability 0-055 - Event B occurs with probabilit.pdf
Event A occurs with probability 0-055 - Event B occurs with probabilit.pdfEvent A occurs with probability 0-055 - Event B occurs with probabilit.pdf
Event A occurs with probability 0-055 - Event B occurs with probabilit.pdf
 
Every process is identified by a process ID number (PID)- The very fir.pdf
Every process is identified by a process ID number (PID)- The very fir.pdfEvery process is identified by a process ID number (PID)- The very fir.pdf
Every process is identified by a process ID number (PID)- The very fir.pdf
 
Eve has intercepted a large cache of text that appears to be encrypted.pdf
Eve has intercepted a large cache of text that appears to be encrypted.pdfEve has intercepted a large cache of text that appears to be encrypted.pdf
Eve has intercepted a large cache of text that appears to be encrypted.pdf
 
Evaluate the significance of ROCE- Earnings per share and the overall.pdf
Evaluate the significance of ROCE- Earnings per share and the overall.pdfEvaluate the significance of ROCE- Earnings per share and the overall.pdf
Evaluate the significance of ROCE- Earnings per share and the overall.pdf
 
Even though Darwin came up with the theory of sexual selection over 15.pdf
Even though Darwin came up with the theory of sexual selection over 15.pdfEven though Darwin came up with the theory of sexual selection over 15.pdf
Even though Darwin came up with the theory of sexual selection over 15.pdf
 
Evaluate the relationship between population density and population di.pdf
Evaluate the relationship between population density and population di.pdfEvaluate the relationship between population density and population di.pdf
Evaluate the relationship between population density and population di.pdf
 
Estimated Annual Life Insurance Premium Rates per $1-000 of Face Value.pdf
Estimated Annual Life Insurance Premium Rates per $1-000 of Face Value.pdfEstimated Annual Life Insurance Premium Rates per $1-000 of Face Value.pdf
Estimated Annual Life Insurance Premium Rates per $1-000 of Face Value.pdf
 
Evaluate- n-11763n+2.pdf
Evaluate- n-11763n+2.pdfEvaluate- n-11763n+2.pdf
Evaluate- n-11763n+2.pdf
 
eternine whether the scathor diagram indicales that a linear relabion.pdf
eternine whether the scathor diagram indicales that a linear relabion.pdfeternine whether the scathor diagram indicales that a linear relabion.pdf
eternine whether the scathor diagram indicales that a linear relabion.pdf
 
estion li Question 3 If the probability distribution for the random va.pdf
estion li Question 3 If the probability distribution for the random va.pdfestion li Question 3 If the probability distribution for the random va.pdf
estion li Question 3 If the probability distribution for the random va.pdf
 

Recently uploaded

The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 
Poster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfPoster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdf
Alexander Litvinenko
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 

Recently uploaded (20)

An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
Word Stress rules esl .pptx
Word Stress rules esl               .pptxWord Stress rules esl               .pptx
Word Stress rules esl .pptx
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
Poster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfPoster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdf
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
 
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17
 
The Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptxThe Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptx
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 Inventory
 

Exercise 2- Implementing Geometry Formulas with functions (10 points) (1).pdf

  • 1. Exercise 2: Implementing Geometry Formulas with functions (10 points) Implement the following functions that return the volume and surface areas of 3D shapes: double cone_volume(double r , double h ) ; // r = radius, h = height double cone_surface(double r , double h ) ; // r = radius, h = height double cube_volume(double a); // a = edge double cube_surface(double a) ; // a = edge double sphere_volume(double r ) ; // r = radius double sphere_surface(double r ) ; // r = radius double cylinder_volume(double r , double h ) ; // r = radius, h = height double cylinder_surface(double r , double h ) ; // r = radius, h = height Write a program that prompts the user to enter whether they have a cone, cube, sphere, or cylinder. - If the user enters "cone", the program then prompts the user to enter two values: radius and height. The program then calls the respective functions to print the volume and surface area of the cone. - If the user enters "cube", the program then prompts the user to enter one value: edge length. The program then calls the respective functions to print the volume and surface area of the cube. - If the user enters "sphere", the program then prompts the user to enter one value: radius. The program then calls the respective functions to print the volume and surface area of the sphere. - If the user enters "cylinder", the program then prompts the user to enter two values: radius and height. The program then calls the respective functions to print the volume and surface area of a cylinder. - If the user enters anything other than cone, cube, sphere, or cylinder, print "Invalid shape."