Assigned: Tuesday February 04, 2003 Deadline: Tuesday February 11, 2003 at MIDNIGHT PROGRAM 4: --------- Write a C++ program that calculates the length, width, perimeter and area of a RECTANGLE. You should create a Rectangle that stores the Cartesian coordinates of the four corners of the rectangle. The constructor calls a set function that accepts four sets of coordinates and verifies that they form a rectangle and that each of these are less than the absolute value of 30. For example, coordinate values of -30, -5, 0, 4, 29 are allowed. Your set function should also make sure that the input coordinates form a rectangle in at most 2 quadrants. For example in the below Figures, the rectangle enclosed with "X"'s is not allowed, and the rectangles enclosed in "o"'s are allowed. Of-course the set function should also make sure that the supplied coordinates indeed form a rectangle. | | 2nd quadrant | 1st quadrant | XXXXXXXXXXXXXXX oooo X | X o o --------X-------------X----o--o----- X | X o o XXXXXXXXXXXXXXX o o | o o | oooo 3rd quadrant | 4th quadrant | | | | | | 2nd quadrant | 1st quadrant | oooooo o o ----------------o----o-------------- o o o o oooooo | 3rd quadrant | 4t quadrant | | You should include member functions that calculate the length, width, perimeter and area. The length is the larger of the two dimensions. You should include a predicate function square that determines if the rectangle is a SQUARE. The rectangle should default to: 0,0 0,10 20,0 20,10 Your program should display the following menu of alternatives. Please Type: "E" (E)nter new coordinates. "V" View rectangle length, width, perimeter and area "D" Display rectangle coordinates "I" Enter multiplier to shrink/grow rectangle. 'E' should take 4 coordinates as input, one coordinate per line. For example you may enter the default as: 0.0 0.0 0.0 10.0 20.0 0.0 10.0 20.0 'V' should print out the length, width, perimeter and area (nicely formatted and descriptive)> 'I' should increase or decrease the rectangles area by a multiplier, for example an input 2 should double the area, and input of 0.5 should shrink the area in half. Each dimension (length, and width) should increase/decrease by the same factor. Let the lower, left coordinate remain fixed, you move the top right corner of the rectangle, and let other coordinates follow. See example below in interaction section. ------------------------------------------------------------------------------ Example interaction: "E" (E)nter new coordinates. "V" View rectangle length, width, perimeter and area "D" Display rectangle coordinates "I" Enter multiplier to shrink/grow rectangle. Please select from menu above > E Enter four coordinates > 5.0 3.0 1.0 3.0 5.0 1.0 1.0 1.0 "E" (E)nter new coordinates. "V" View rectangle length, width, perimeter and area "D" Display rectangle coordinates "I" Enter multiplier to shrink/grow rectangle. (change the top right corner of the rectangle) Please select from menu above > V length = 4.0 width = 2.0 perimeter = 12.0 area = 8.0 "E" (E)nter new coordinates. "V" View rectangle length, width, perimeter and area "D" Display rectangle coordinates "I" Enter multiplier to shrink/grow rectangle. (change the top right corner of the rectangle) "E" (E)nter new coordinates. "V" View rectangle length, width, perimeter and area "D" Display rectangle coordinates "I" Enter multiplier to shrink/grow rectangle. (change the top right corner of the rectangle) Please select from menu above > I Please enter shrink/grow multiplier: > 4 "E" (E)nter new coordinates. "V" View rectangle length, width, perimeter and area "D" Display rectangle coordinates "I" Enter multiplier to shrink/grow rectangle. (change the top right corner of the rectangle) Please select from menu above > D 9.0 5.0 1.0 5.0 9.0 1.0 1.0 1.0 "E" (E)nter new coordinates. "V" View rectangle length, width, perimeter and area "D" Display rectangle coordinates "I" Enter multiplier to shrink/grow rectangle. (change the top right corner of the rectangle) Please select from menu above > D length = 8.0 width = 4.0 perimeter = 24.0 area = 32.0 ------------------------------------------------------------------------------ Erroneous input (for the four coordinates should cause something like the below output). Coordinates do not form a rectangle. Coordinate not in specified area. Rectangle is in more than 2 quadrants. Note: you also need to specify if the rectangle form a SQUARE. ------------------------------------------------------------------------------ OTHER REQUIREMENTS: ------------------- * Proper commented code * Modularized program * Good software engineering techniques, hints in text book. * You must submit at least the following files (i.e., all the files necessary to compile your program): README.txt Rectangle.cpp Makefile To submit the files, you will need to use the submit program. Your files need to be under a common subdirectory called "1730_program4". Execute the below command line while in your homedirectory: submit 1730_program4 cs1730 NOTE: you need to be LOGGED ONTO ajax when you execute the submit command.