for this lab you will find the area of an irregularly shaped room with the shape shown above.


Ask the user to enter the values for the sides A, B, C, D, and E and print out the total room area.


Remember the formula for finding the area of a rectangle is length * width and the area of a right triangle is 0.5 * base * height.


Please note the final area should be in decimal formula.


Sample run :


Enter side A : 11


Enter side B : 2


Enter side C : 4


Enter side D : 7


Enter side E : 1


Output :


Room area: 53.5

Respuesta :

Answer:

C++.

Explanation:

#include <iostream>

using namespace std;

//////////////////////////////////////////////////////////////////////////////

void input(int &side, char side_name) {

   cout<<"Enter side "<<side_name<<": ";

   cin>>side;

   while (cin.fail())  {

       cin.clear();

       cin.ignore();

       cout<<"Not a valid number, Please re-enter: ";

       cin>>side;

       cout<<endl;

   }

}

//////////////////////////////////////////////////////////////////////////////

int main() {

   int A, B, C, D, E;

   int total_room_area = 0;

//////////////////////////////////////////

   input(A, 'A');

   input(B, 'B');

   input(C, 'C');

   input(D, 'D');

   input(E, 'E');

//////////////////////////////////////////

   // Please specify the exact formula for calculating "Room area".

   cout<<"Room area: "<<total_room_area;

   return 0;

}

Answer:

Edhesive Python Answer:

A=int(input("Enter side A: "))

B=int(input("Enter side B: "))

C=int(input("Enter side C: "))

D=int(input("Enter side D: "))

E=int(input("Enter side E: "))

R= A*B

b=A-C

T=1/2*E*b

s=D-(B+E)

S=s*b

TA=S+T+R

print("Room Area: "+ str(TA))

Explanation:

Hope this helps :)