Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design and code a Python program that will compute and return the area of both a

ID: 3638404 • Letter: D

Question

Design and code a Python program that will compute and return the area of both a triangle and rectangle with the same base and height.

Input specification. The program will ask the user to input values for both base and height,expressed in linear units.The program should be able to accept either integer or floating-point values.

Output specification. The program will display two statements in this general format:The area of a ____with a height of ____units and a base of units is ____square units.

Exercises deliverables:
Program pseudo code.
Program flow chart or structure chart.
Executable code

Explanation / Answer

#include #include main() { float base,height,area; int ch; printf("enter the base:"); /* these are the base and height of rectange and triangle scanf("%f",&base); printf("enter the height:"); scanf("%f",&height); printf("choose 1 for area of the triangle and choose 2 for area of the rectangle:"); scanf("%d",&ch); if(ch==1) { area=1/2(base)*height; printf("the area of the triangle is :%f",area); } if(ch==2) { area=base*height; printf("the area of the rectangle is :%f",area); } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote