Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please do this asap Step 1. Problem Statement and Requirements In this lab exercise you must write a function that determines whether a point lies

Please do this asap
image text in transcribed

Step 1. Problem Statement and Requirements In this lab exercise you must write a function that determines whether a point lies inside a rectangle. The point and rectangle are both specified using arrays of floating point values. Use the multi source file model to create your solution. This signifies that you will create a header file InRectang1e . h, and a source code file InRectang1e. c. The function must match the following declaration: #define POINTS 2 #define CORNERS 4 int lnRectang1e( float pt [POINTS] , float rect[CORNERS] ) ; Put this function (on its own, do not include a main function) in a file called InRectang1e. c Parameter pt (POINTS I defines a point on the plane: pt [01 isthex-coordinate, pt (11 is they- coordinate. Parameter rect (CORNERS] defines a rectangle on the same plane. rect and rect[l] define the x- and y- coordinates respectively Of one corner Of the rectangle. [2] and rect[3J define the opposite Corner. Coordinates may be any valid floating point value, including negative values. The function returns the integer value O (false) for any point that lies outside the rectangle, and 1 (true) for any Other point (i.e. points inside and on the boundary Of the rectangle). Step 2 - Design Hint: Keep in mind that there can be two ways of describing a rectangle using its top and bottom corners: 1. Top left corner + bottom right corner h) 2. Top right corner + bottom left corner To make your code more straightforward and mana eable, first, have your code transform the secon way of describing a rectangle into the first way: ma . h may be helpful in solving this lab exercise. So, have a Hint: Functions declared in look at the content of math h Step 4 - Testing It is very common to represent geometric figures using small, fixed-size arrays like this. Note that the size of the arrays are specified in the function declaration. This allows the compiler to check that the function is called with a correctly-sized array. Since this lab exercise calls for a function only, and not a complete program, you need to write a program to test your function. Feel free to use the test driver posted on our course web site when testing your function. This test driver tests whether the function works correctly using three test cases. Here is a diagram depicting these three test cases: Step 4 lstillg (cont'd) Note the syntax for initializing arrays with constant values at compile-time, e.g. line 16 in the test driver. This only works for constant values. This is to say that this code would not compile: int size 4; // retine a rectangle trom to (2.2' float You mut always write a test driver for your functions. Consider an untested function to be incorrect. Once a function passes all the tests you can think of, you might cautiously believe it might be correct. In software engineering, like any quality-focused pursuit, it helps to be skeptical. It is convenient to use the multi source file model by creating two source files: one containing the InRectang1e() function, and one with main ( ) (i.e., the test driver). You can start out with the provided testDriver. c and extend it by adding more test cases in order to more thoroughly test your InRectang1e (...) function. Step 4- Testing : This is a great opportunity for you to practise creating a makefile makef i I e. To do so, download and modify any makefile found on our course web site. Hint: Do not forget to link the math library with your files.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago