Due date: Wednesday, April 07, 2010, 11:55pm.
Task 1 (50 points)
Complete the code already written in file task1.cpp, that behaves as follows:
- It asks the user to specify two points on the plane, as (x, y) coordinates.
- It computes the Euclidean distance between the two points, and prints out that distance.
The Euclidean distance between points (x1, y1) and (x2, y2) is defined as:
sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2))
For example: the Euclidean distance between point (1.2,2.5) and point (3.1,5.6) is 3.6359.
Note that:
- The main function is already defined in file task1.cpp. You are not allowed to modify that. You need to complete the code, so that the main function behaves correctly.
- You should define structures and declare functions in a header file called "point.h".
- The existing code in task1.cpp already includes math.h, a header file that allows you to use the sqrt function to compute square roots. sqrt(x) gives you the square root of x.
Task 2 (50 points)
Complete the code already written in file task2.cpp, that behaves as follows:
- It asks the user to specify the address and price of two houses that are on sale.
- It prints out which of the two houses is cheaper.
Note that:
- The main function is already defined in file task2.cpp. You are not allowed to modify that. You need to complete the code, so that the main function behaves correctly.
- You should define structures and declare functions in a header file called "house.h".
- The structure for house should include:
- A street number.
- A street name. If the street name is "Greek Oak Street", just represent it as "Green_Oak_Street", with underscores instead of spaces, so that it is easy for the user to enter in scanf.
- A price.
How to submit
Submisions are only accepted via WebCT. The submission should include your C or C++ source files, and answers.doc. Do not submit entire project directories, or anything else except for the .c and .cpp files and the answers.doc file.
Your answers.doc file should be a single Microsoft Word file that includes:
- Your name and UTA ID number at the top.
- A copy of your code for each task where you had to write code.
Make sure that your answers.doc file is easy to parse, and that it is easy for us to figure out which part corresponds to which task. Feel free to use headings such as "start of copy of task1.c".
We try to automate the grading process as much as possible. Not complying precisely with instructions causes a significant waste of time during grading, and thus points will be taken off for failure to comply, and/or you may receive a request to resubmit.
Submission checklist
- Was the assignment submitted via WebCT?
- Did answers.doc contain your name and UTA ID?
- Did the submission include files your C or C++ source files, answers.docs, and nothing else?