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

Create a struct called rectangle_t that has fields for the length and width of t

ID: 3659055 • Letter: C

Question

Create a struct called rectangle_t that has fields for the length and width of the rectangle Create three methods that work with your rectangle structure: rectangle_t create_rectangle(int len, int wid); int lessThan(rectangle_t one, rectangle_t two); (this should return 1 if the area of rectangle one is less than the area of rectangle two; otherwise it should return 0) void display_rectangle(rectangle_t rect); (this should print out the length, width, and area of rect) Write a main method that creates an array of five rectangle_t objects (you can just hardcode their dimensions). Print out all of the rectangles in your array. Then sort your array using a selection sort (this is in your textbook) and your lessThan method. Finally, print out the sorted array of rectangles.

Explanation / Answer

#include using namespace std; struct rectangle_t{ double length,width; rectangle_t(); void create_rectangle(int len, int wid); }; int lessThan(rectangle_t one, rectangle_t two); void display_rectangle(rectangle_t rect); rectangle_t::rectangle_t(){ length=1; width=1; } void rectangle_t::create_rectangle(int len, int wid){ if(len>0) length=len; else { cout
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