lab 4: areas of irregularly-shaped quadrilateralsEN47/COMP9, Fall 2009 the problemIn this lab, you will write a program to compute the area of a
number of quadrilaterals. Your program should keep track of the
maximum area, the minimum area, and the running average of all areas
computed so far. The user will specify the quadrilaterals by the
x-coordinates and y-coordinates of their vertices in clockwise order
around the boundary.
As in the previous lab, you will write several functions:
The user interaction with your program should look something like below. The underlined text is entered by the user.
This program will compute the areas of several 4-sided gardens
given the integer coordinates of the vertices of each garden in
clockwise order around the boundary of the quadrilateral.
It will also keep the running average, max, and min garden size.
How many gardens? 2
For each of the quadrilateral gardens, please give the x-coordinate
and y-coordinate of each of the four vertices separated by a space,
one vertex per line
Garden #1?
1 3
5 7
11 1
3 1
NUM AREA MIN MAX AVG
1 32 32 32 32
Garden #2?
5 7
8 14
14 5
11 1
NUM AREA MIN MAX AVG
2 55.5 32 55.5 43.75
The area of 2 gardens was computed.
In the case of zero gardens, simply print " the algorithmHere is one possible approach to this problem. You are welcome to use this as a guide in developing your solution.
After reading the problem description and sample algorithm, work out your approach on paper first. You are encouraged and expected to collaborate with classmates on this part. the programWhen you are finally ready to start writing code, create a directory for
today's lab and a file called
When you are satisfied that your program is correct, hand it in using: provide comp9 lab4 quads.cpp extra creditModify your program to produce the correct quadrilateral area regardless of whether the vertices are entered in clockwise or counter clockwise fashion. There are easy and hard ways of doing this! Try to find the easy way. Write your code in a new file named provide comp9 lab4ec quads_extra.cpp |