The Most Rapid Essay Writing Service For Your Academic Success

Become a better student and get high grades with our professional writers.

Welcome to the #1 paper writing service, where each essay writer knows your needs and saves you from endless tasks!

  • We cover all disciplines and academic styles.
  • We meet your deadlines and formatting requirements.
  • We ask nothing but your “thank you” in return.

Entrust our essay writing service with your homework today—and forget about dull tasks and poor grades forever.

C++ Programming 1

lab involves some scientific data processing. You will download a Geographical Database File which contains the coordinates of the boundaries of the 48 connected states and the five great lakes and write a program that draws maps requested by the user.
Download the file usamap.txt from the class web site. The format of the file is very simple; it describes the outlines of the 48 older states plus the five great lakes. Here is the beginning of the file:
-1 -1 AL
and it continues like that for a long time. The first line FL indicates that this is the description of a state: FL is the postal abbreviation for Florida. The next 21 lines give the
coordinates of a point along the border of the state. The coordinates are actually longitude and latitude measured in thousandths of a degree but you can treat them simply as x and y values. The two -1s after the list of numbers are simply to give you an easy way of telling that the list has finished (no real data in this file is ever negative). Then you see AL introducing the next state Alabamas description.
The whole file is just like that. First a states abbreviation then a list of coordinates then -1 -1 all repeated 55 times. Notice that the coordinates of the last point are the same as the coordinates of the first point (81500 30666). This is true of every states description; they all make nice closed figures. The coordinates 81500 30666 represent the point 3023 degrees North of the equator and 8112 degrees West of the Greenwich meridian.
At the end of the file which looks like this…
… youll find the word END. The last state Kansass description ends as usual with -1 -1 then the word END appears. No state has END as its postal abbreviation. There is no data following the END.
For your information these are the extreme data values that appear in the file:
Minimum Longitude (x) Maximum Longitude (x) Minimum Latitude (y) Maximum Latitude (y)
The states all have their standard two-letter postal abbreviations. The great lakes are given three-letter abbreviations: LKE LKH LKM LKO and LKS.
1. Draw Florida
Write a program that opens a reasonably large graphics window (you decide the size) and draws the outline of the first state that appears in the data file (i.e. Florida). You will have to scale and shift the coordinates before plotting as one of the points in Florida is (81500 30666) and theres no way youre going to get a window that big. Make sure your picture comes out the right way round:
Draw any state
Modify your program so that it asks the user to enter a states (or lakes) abbreviation and then draws that state. It should not draw anything else just the outline of the selected state. Do not worry about sizing the window to fit that state properly. Make the window big enough to draw the whole country and just draw the one state in its correct position.
Did you get it right?
Two of the states Michigan (MI) and Virginia (VA) are not contiguous; they come in two sections separated from each other by water. The two sections of these states have their own descriptions in the data file: there are two sections beginning with VA and two beginning with MI. Make sure that if the user requests a non-contiguous state all of its portions are drawn.
Label the States
There is a second data file associated with this lab called capitals.txt. Dowload it too. It has exactly 50 lines and this is what the first four look like.
The file has a line for each state and each line contains exactly four pieces of information: the states postal abbreviation the name of its capital and the latitude and longitude of its capital.
Notice that when a name consists of more than one word an underline is used instead of a space so that you can use the >> operator to read the file without trouble. Notice also that in this file latitude and longitude are measured in degrees as floating point numbers.
Improve your program so that every time it draws a state it searches through this second file to find that states capital. It should draw on the map at the correct position to mark the capital a star with the states abbreviation beside it. This is Washington Not-D.C.
Remember that youll need to reset the capitals file to its beginning after each search or therell be trouble.
Make it incremental
Add a loop to your program. After creating the window big enough to draw the whole country it should enter the loop repeatedly asking the user to enter a state abbreviation. For each abbreviation entered it should add the outline of that state to what has already been drawn so that the user can build up a map of many states if desired. Remember to open the file each time round the loop and close it before the end of the loop; that way youll be able to read it afresh from the beginning each time.
Make it do everything.
If the user enters ALL instead of a state abbreviation your program should draw the outlines of all the states (in the same window) so that a map of the whole country appears. Of course the program should still draw individual states if the input is not ALL. The capitals should also be marked but you may want to select a smaller font to make it fit.
The map will look a bit over-crowded unless your create a really big window but there isnt much that could reasonably be done about that.
EXTRA CREDIT.
Im sure you remember that the library contains these three useful functions: wait_for_mouse_click() get_click_x() and get_click_y(). After drawing the whole country make your program wait for the user to click the mouse somewhere then report back the name of the state capital closest to that position.
Even better there is another function get_pixel_color(x y) which returns the colour of the pixel at position x y encoded as an int. If you colour all the states in with different colours when drawing their outlines you can use this function to tell which state the user clicked on.
Make your program into a geography quiz. Dont draw the state capitals or names initially. Instead choose a random state and tell the user to click on it. Dont let them go home until they have clicked in the right place.
Links to use:http://rabbit.eng.miami.edu/class/een118/labs/usamap1.txt
http://rabbit.eng.miami.edu/class/een118/labs/capitals.txt

You can leave a response, or trackback from your own site.
Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes