#include <stdio.h>
//this structure represents walls in a room
struct wall{
int height;
int length;
};
//this structure represents a room
struct room{
wall north,south,east,west,updn;
};
//this function calculates the area of a wall
int area (wall mw){
return mw.height*mw.length;
}
//this function calculates the area of the floor and ceiling
int updown (room mc){
return mc.north.length*mc.east.length;
}
//this function calculates the total area of a room
int roomarea (room mr){
return area(mr.north)+area(mr.south)+area(mr.east)+area(mr.west)+updown(mr)+updown(mr);
}
//this function calculates the area of the walls and the ceiling of a room
int paintarea (room ma){
return area(ma.north)+area(ma.south)+area(ma.east)+area(ma.west)+updown(ma);
}
//this function calculates the total area of the floor
int carpetarea (room mp){
return updown(mp);
}
int main()
{
room r;
//take in the room height and assign it to the nort south west and east walls
printf ("Height\n");
scanf ("%d", &r.north.height);
r.south.height = r.north.height;
r.west.height = r.north.height;
r.east.height = r.north.height;
//take in the room length and assign it to the north and south walls
printf ("Length\n");
scanf ("%d", &r.north.length);
r.south.length = r.north.length;
//take in the room width and assign it to the east and west walls
printf ("Width\n");
scanf ("%d", &r.west.length);
r.east.length = r.west.length;
//assign the functions roomarea paintarea and carpetarea to integers
int myarea = roomarea (r);
int mypaintarea = paintarea (r);
int mycarpetarea = carpetarea (r);
//output the results
printf ("%d foot area\n%d paint area\n%d carpet area\n", myarea, mypaintarea, mycarpetarea);
}