SThis program allows the user to choose various geometry caleulations from a menu. elif choice = TRIANGLE_PERIMETER CHOICE: Scall the triangle perimeter funetion triangle _perimeter () print () elif choice QUIT_CHOICE: print ('Exiting the program) else: #Problem statement SAlgorithm #Imports print ('Error: Invalid selection!11') The main function definition. def main () : *Choice variable controls the loop tand holds the user's menu choice. Task #1 the display menu function displays a menu. #The display _menu function displays a menu. choice 0 Task #2 define void functions. *Named constanta for the menu choices CIRCLE_AREA_CHOICE 1 RECTANGLE_AREA_CHOICE = 2 TRIANGLE AREA CHOICE = 3 CIRCLE_CIRCUMFERENCE_CHOICE = 4 RECTANGLE_PERIMETER_CHOICE = 5 TRIANGLE_PERIMETER_CHOICE -6 QUIT CHOICE = 7 #1) circle_area function #2) rectangle_area function 43) triangle_area function #4) cirele_eireumference funetion while (choice != QUIT_CHOICE) : Task #1 display the menu. tcall the display_menu function #5) rectangle perimeter funetion Get the user's choice. choice = int (input ('Enter your choice: ')) #6) triangle perimeter function Task 13 function calls. #Perform the user selected action. if choice = CIRCLE AREA_CHOICE: tcall the cirele_area funetion eirele area () print () elif choice == RECTANGLE_AREA_CHOICE: tcall the rectangle_area function rectangle_area () print () elif choice = TRIANGLE_AREA_CHOICE: tcall the triangle_area funetion triangle_area () print () elif choice == CIRCLE_CIRCUMFERENCE_CHOICE: Scall the eirele_circumference funetion circle_circumference () print () elif choice == RECTANGLE_PERIMETER_CHOICE: tcall the rectangle_perimeter function rectangle perimeter () print () Task 14 define value-returning funetions. +call the main funetion. main ()

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question
100%

The Instructions, Question and Source Code needed are in the photos.

Bb Interactive Video 8 - 03/02/2 X
Bb Students are required to produce X
b IntroductionFunctions are comm X
New Tab
x +
->
A learn-us-east-1-prod-fleet02-xythos.content.blackboardcdn.com/5df7f1d815fec/11465658?X-Blackboard-Expiration=1614945600000&X-Blackboard...
E Apps
Students are required to produce a term project on an aspect of.
1 / 2
50%
+
4. Write a function called circle circumference that prompts the user for the radius of a circle and prints
the circumference using the formula C= 2ar.
5. Write a function called rectangle_perimeter that prompts the user for the length and the width of a
rectangle and prints the perimeter of the rectangle using the formula P = 21 +2w.
6. Write a function called triangle perimeter that prompts the user for the lengths of the three sides of the
triangle and prints the perimeter of the triangle which is calculated by adding up the three sides.
Task #3 function calls
Add lines in the main function to execute the application. In the main function there is a while structure that
further supports the mainline logic of the application. The calculation function call for each menu choice must
be implemented here.
1. Call each of the calculation functions from the while loop structure.
2. Create an evaluation table and manually calculate results for all six menu item calculations.
3. Run and test the program using data from the table in step 3. Fix syntax, logic, and runtime errors.
Lab 5: Functions
Objectives
• Be able
• Be able to call void functions
Be able to define value-returning functions
Be able to pass arguments to functions
Be able to assign the return expression of a value-returning function
define void functions
Introduction
Functions are commonly used to break a problem down into small manageable pieces. A large task can be
broken down into smaller tasks, e.g., functions, that contain the details of how to complete that small task. The
larger problem is then solved by implementing the smaller tasks in the correct order via mainline program logic.
Such application
rewriting the code each time.
allows for efficiencies
can be called as many
needed without
Task #4 value-returning functions
Create a new main.py source code file in the IDE. Copy and paste the solution from Task #3 into the IDE. In
the new source code file, for each of the following statements modify the function, each function should be
converted to a value-returning function. That is, a function that has a return statement and that returns the result
of the calculation to the part of the program that called it.
1. Rewrite the function called circle area, it should take in the radius of a circle and return the area using
the formula A=ar. Print the result of the returm.
2. Rewrite the function called rectangle_area, it should take in the length and width of a rectangle and
return the area using the formula A = lw. Print the result of the return.
3. Rewrite the function called triangle_area, it should take in the base and height of a triangle and return
the area using the formula A = Abh. Print the result of the return.
4. Rewrite the function called circle circumference, it should take in the radius of a circle and return the
circumference using the formula C= 2nr. Print the result of the return.
5. Rewrite the function called rectangle_perimeter, it should take in the length and the width of a rectangle
and return the perimeter of the rectangle using the formula P = 21 +2w. Print the result of the return.
6. Rewrite the function called triangle_perimeter, it should take in the lengths of the three sides of the
triangle and return the perimeter of the triangle which is calculated by adding up the three sides. Print
the result of the return.
7. Run and test the program. Fix syntax, logic, and runtime errors. Print the result of the return.
Task #1 Application Download and Review
This task will use the geometry.py source code file. It can be downloaded from Blackboard; it is incomplete.
Since there is a large part of the program missing, the program will run but appear to do nothing except wait. In
fact, it is waiting for end user input, but the end user does not have a menu to choose from.
1. Download the geometry.py file
2. Upload and then paste the source code into main.py of the online IDE.
3. Execute the source code.
4. Create a function called display menu that will simply print instructions for the user.
a. The menu should appear to the user as follows:
This is a geometry calculator
Choose what you would like to calculate
1. Find the area of a circle
2. Find the area of a rectangle
3. Find the area of a triangle
4. Find the circumference of a circle
5. Find the perimeter of a rectangle
6. Find the perimeter of a triangle
Enter the number of your choice:
Task #5 Document and Submit
Create a Word document. Create a table in the document and record the results of the manual calculations.
Copy and paste the Python source code IDE Link for the void and value-returning functions. Input sample
screenshots of the program's output.
5. Add code in the main function that calls the display_menu function, its location is indicated in the
comments.
6. Debug, save, and run the program.
a. Results should produce the menu, it should allow the user to choose any option, the result will
always return zero.
Submit the following via Blackboard:
Python source code IDE Link for both solutions in the write submission tap.
Word document with the following:
Experiment results
Python IDE links
Screen output from at least one execution of the program
Task #2 void functions
For each of the following statements, write a function.
1. Write a function called circle_area that prompts the user for the radius of a circle and prints the area
using the formula A =ar.
2. Write a function called rectangle_area that prompts the user for the length and width of a rectangle and
prints the area using the formula A = lw.
3. Write a function called triangle_area that prompts the user for the base and height of a triangle and prints
the area using the formula A = %bh.
Page I of 2
Page 2 of 2
10:38 PM
2 Type here to search
w
3/4/2021
..
...
II
Transcribed Image Text:Bb Interactive Video 8 - 03/02/2 X Bb Students are required to produce X b IntroductionFunctions are comm X New Tab x + -> A learn-us-east-1-prod-fleet02-xythos.content.blackboardcdn.com/5df7f1d815fec/11465658?X-Blackboard-Expiration=1614945600000&X-Blackboard... E Apps Students are required to produce a term project on an aspect of. 1 / 2 50% + 4. Write a function called circle circumference that prompts the user for the radius of a circle and prints the circumference using the formula C= 2ar. 5. Write a function called rectangle_perimeter that prompts the user for the length and the width of a rectangle and prints the perimeter of the rectangle using the formula P = 21 +2w. 6. Write a function called triangle perimeter that prompts the user for the lengths of the three sides of the triangle and prints the perimeter of the triangle which is calculated by adding up the three sides. Task #3 function calls Add lines in the main function to execute the application. In the main function there is a while structure that further supports the mainline logic of the application. The calculation function call for each menu choice must be implemented here. 1. Call each of the calculation functions from the while loop structure. 2. Create an evaluation table and manually calculate results for all six menu item calculations. 3. Run and test the program using data from the table in step 3. Fix syntax, logic, and runtime errors. Lab 5: Functions Objectives • Be able • Be able to call void functions Be able to define value-returning functions Be able to pass arguments to functions Be able to assign the return expression of a value-returning function define void functions Introduction Functions are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks, e.g., functions, that contain the details of how to complete that small task. The larger problem is then solved by implementing the smaller tasks in the correct order via mainline program logic. Such application rewriting the code each time. allows for efficiencies can be called as many needed without Task #4 value-returning functions Create a new main.py source code file in the IDE. Copy and paste the solution from Task #3 into the IDE. In the new source code file, for each of the following statements modify the function, each function should be converted to a value-returning function. That is, a function that has a return statement and that returns the result of the calculation to the part of the program that called it. 1. Rewrite the function called circle area, it should take in the radius of a circle and return the area using the formula A=ar. Print the result of the returm. 2. Rewrite the function called rectangle_area, it should take in the length and width of a rectangle and return the area using the formula A = lw. Print the result of the return. 3. Rewrite the function called triangle_area, it should take in the base and height of a triangle and return the area using the formula A = Abh. Print the result of the return. 4. Rewrite the function called circle circumference, it should take in the radius of a circle and return the circumference using the formula C= 2nr. Print the result of the return. 5. Rewrite the function called rectangle_perimeter, it should take in the length and the width of a rectangle and return the perimeter of the rectangle using the formula P = 21 +2w. Print the result of the return. 6. Rewrite the function called triangle_perimeter, it should take in the lengths of the three sides of the triangle and return the perimeter of the triangle which is calculated by adding up the three sides. Print the result of the return. 7. Run and test the program. Fix syntax, logic, and runtime errors. Print the result of the return. Task #1 Application Download and Review This task will use the geometry.py source code file. It can be downloaded from Blackboard; it is incomplete. Since there is a large part of the program missing, the program will run but appear to do nothing except wait. In fact, it is waiting for end user input, but the end user does not have a menu to choose from. 1. Download the geometry.py file 2. Upload and then paste the source code into main.py of the online IDE. 3. Execute the source code. 4. Create a function called display menu that will simply print instructions for the user. a. The menu should appear to the user as follows: This is a geometry calculator Choose what you would like to calculate 1. Find the area of a circle 2. Find the area of a rectangle 3. Find the area of a triangle 4. Find the circumference of a circle 5. Find the perimeter of a rectangle 6. Find the perimeter of a triangle Enter the number of your choice: Task #5 Document and Submit Create a Word document. Create a table in the document and record the results of the manual calculations. Copy and paste the Python source code IDE Link for the void and value-returning functions. Input sample screenshots of the program's output. 5. Add code in the main function that calls the display_menu function, its location is indicated in the comments. 6. Debug, save, and run the program. a. Results should produce the menu, it should allow the user to choose any option, the result will always return zero. Submit the following via Blackboard: Python source code IDE Link for both solutions in the write submission tap. Word document with the following: Experiment results Python IDE links Screen output from at least one execution of the program Task #2 void functions For each of the following statements, write a function. 1. Write a function called circle_area that prompts the user for the radius of a circle and prints the area using the formula A =ar. 2. Write a function called rectangle_area that prompts the user for the length and width of a rectangle and prints the area using the formula A = lw. 3. Write a function called triangle_area that prompts the user for the base and height of a triangle and prints the area using the formula A = %bh. Page I of 2 Page 2 of 2 10:38 PM 2 Type here to search w 3/4/2021 .. ... II
#This program allows the user to choose various geometry calculations
elif choice == TRIANGLE PERIMETER CHOICE:
#call the triangle_perimeter function
triangle_perimeter ()
print ()
elif choice == QUIT CHOICE:
from
a menu.
#Problem statement
#Algorithm
print ('Exiting the program.')
else:
#Imports
print ('Error: Invalid Selection!!!')
#The main function definition.
def main () :
#Task #1 the display_menu function displays a menu.
#The display_menu function displays a menu.
#Choice variable controls the loop
#and holds the user's menu choice.
choice = o
#Task #2 define void functions.
#Named constants for the menu choices
#1) circle_area function
CIRCLE AREA CHOICE = 1
RECTANGLE AREA CHOICE = 2
TRIANGLE AREA CHOICE = 3
# 2) rectangle_area function
CIRCLE CIRCUMFERENCE CHOICE = 4
RECTANGLE PERIMETER CHOICE = 5
TRIANGLE PERIMETER CHOICE = 6
#3) triangle_area function
QUIT CHOICE = 7
while (choice != QUIT_CHOICE) :
#Task #1 display the menu.
#call the display_menu function
# 4) circle_circumference function
#5) rectangle_perimeter function
#Get the user's choice.
choice = int (input ('Enter your choice: ') )
#6) triangle_perimeter function
#Task #3 function calls.
#Perform the user selected action.
#Task #4 define value-returning functions.
if choice == CIRCLE AREA_CHOICE:
#call the circle area function
circle_area ()
print ()
elif choice == RECTANGLE AREA CHOICE:
#call the rectangle area function
rectangle_area ()
print ()
elif choice == TRIANGLE AREA CHOICE:
#Call the main function.
main ()
#call the triangle area function
triangle_area ()
print ()
elif choice == CIRCLE CIRCUMFERENCE CHOICE:
#call the circle circumference function
circle circumference ()
print ()
elif choice == RECTANGLE PERIMETER CHOICE:
#call the rectangle perimeter function
rectangle_perimeter ()
print ()
Transcribed Image Text:#This program allows the user to choose various geometry calculations elif choice == TRIANGLE PERIMETER CHOICE: #call the triangle_perimeter function triangle_perimeter () print () elif choice == QUIT CHOICE: from a menu. #Problem statement #Algorithm print ('Exiting the program.') else: #Imports print ('Error: Invalid Selection!!!') #The main function definition. def main () : #Task #1 the display_menu function displays a menu. #The display_menu function displays a menu. #Choice variable controls the loop #and holds the user's menu choice. choice = o #Task #2 define void functions. #Named constants for the menu choices #1) circle_area function CIRCLE AREA CHOICE = 1 RECTANGLE AREA CHOICE = 2 TRIANGLE AREA CHOICE = 3 # 2) rectangle_area function CIRCLE CIRCUMFERENCE CHOICE = 4 RECTANGLE PERIMETER CHOICE = 5 TRIANGLE PERIMETER CHOICE = 6 #3) triangle_area function QUIT CHOICE = 7 while (choice != QUIT_CHOICE) : #Task #1 display the menu. #call the display_menu function # 4) circle_circumference function #5) rectangle_perimeter function #Get the user's choice. choice = int (input ('Enter your choice: ') ) #6) triangle_perimeter function #Task #3 function calls. #Perform the user selected action. #Task #4 define value-returning functions. if choice == CIRCLE AREA_CHOICE: #call the circle area function circle_area () print () elif choice == RECTANGLE AREA CHOICE: #call the rectangle area function rectangle_area () print () elif choice == TRIANGLE AREA CHOICE: #Call the main function. main () #call the triangle area function triangle_area () print () elif choice == CIRCLE CIRCUMFERENCE CHOICE: #call the circle circumference function circle circumference () print () elif choice == RECTANGLE PERIMETER CHOICE: #call the rectangle perimeter function rectangle_perimeter () print ()
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 9 images

Blurred answer
Knowledge Booster
Database connectivity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr