Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 Surface Area = Base Height + Base Width The total surface area is the sum of the triangular area and rectangular area. Complete
1 Surface Area = Base Height + Base Width The total surface area is the sum of the triangular area and rectangular area. Complete the following code to compute the total surface area of the shape. You should name this project as Lab6A. * This program prompts for and reads in the value of height, base, and width in feet. This program uses two functions: Train_area and Rect_area to calculate the area of the triangle and the area of the rectangle, respectively. The following parameters: height, base, and width have been declared as floating-point number on the main function. * The function declaration (prototype), function definition, and function call for Trian area have been shown on the code. The parameters: base, and height have been passed to Trian_area function to calculate the area of the triangular area. The value returned by Trian_area function has been assigned to a variable named areal. Task 1: Now, you need to work on the function named Rect area which calculates the rectangular area of shape. You need to write function declaration (prototype), function definition, and function call for Rect area function. You need to pass local variable base and width to the Rect area function. The Rect_area function returns the area of the rectangle to the main. You will assign the value returned by this function to area2. Task 2: Now, add rectangle area and triangle area on the main to calculate the total surface area of the shape. Now, print total surface area of the shape on the terminal according to sample output. #include using namespace std; float Trian_area(float base, float height); // Function declaration for Train area 1/ Write function declaration for Rect_area int main() // Variable declaration float base, height, width, areal, area2, total_area; coutc >base>>height>>width; // Function call to compute triangle area areal- Trian_area(base, height); //Function call to compute rectangle area // write code here // Add areal and area2 to compute total surface area and print total surface area // write code here // Function definition for Train area float Trian_area(float base, float height) return 0.5 base height; //Function definition for Rect area // write code here Sample output 1: Enter the value of base, height and width in feet: 10 30 20 Total surface area of the shape: 350 square feet
Step by Step Solution
★★★★★
3.38 Rating (160 Votes )
There are 3 Steps involved in it
Step: 1
Source code of the program is given belowDetailed comments are included for bette...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started