Students:
This content is controlled by your instructor, and is not zyBooks content. Direct questions or concerns about this content to your instructor. If you have any technical issues with the zyLab submission system, use the Trouble with lab button at the bottom of the lab.
LAB*: Creating an Elevation Map
The Topography of Innovation Island
This project focuses on creating a 2D array of elevations representing a topographical map for a fictional island:
[Click here if you cannot see the above image of the elevation map.]
The island is a perfect rectangle 19 squares wide and 15 squares high, where the outer squares all have elevation 0.0, representing the ocean. The island terrain is composed of 5 hills (shown as red Xs on the map):
Hill Name Ada's Apex
Location of Peak (x,y) (12, 9)
Height 20.0
Steepness (or Slope) 0.25
Turing's Top
(4, 3)
20.0
0.33
Hill Name |
Location of Peak (x,y) |
Height |
Steepness (or Slope) |
Babbage's Bluff |
(6, 13) |
15.0 |
0.33 |
Hopper's Hill |
(14, 2) |
15.0 |
0.5 |
Katherine's Cliff |
(1, 9) |
10.0 |
0.5 |
Note: the 5 hills are named after 5 computationally-focused innovators, namely Ada Lovelace ("World's First Programmer"), Alan Turing ("Father of Computer Science"), Charles Babbage ("Father of the Computer"), Grace Hopper ("Early Pioneer of Programming"), and Katherine Johnson (NASA mathematician who pioneered the use of computers for complicated scientific and engineering calculations and was portrayed as a lead character in the recent Hidden Figures movie, which highlighted the important work of black female mathematicians at NASA that too often gets overlooked). I encourage you to read about all of their stories. Wikipedia is a good place to start.
The elevation at any (x, y) location on the island can be calculated by modeling each hill as a
Gaussian Bump and summing up the contributions from all 5 hills as follows:
[Click here if you cannot see the image of the elevation equation.]
where xi, yi, hi, and si are the (x, y) locations, heights, and steepnesses for each of the 5 hills given in the table above.
Programing Tasks
Some of the tasks require general, proper functionality of a user-defined function and struct data type. Some of the test cases involve unit testing of your function, independent of your calls from main(). For this project, organize all code in one file, namely main.c.
Define a struct data type titled Hill that has the following subitems:
a char array of length 20 titled name, which stores the name of the hill.
an int array of length 2 titled loc, which stores the (x, y) coordinates, in order, for the location of the peak of the hill.
a double variable titled height, which stores the height of the hill.
a double variable titled slope, which stores the steepness parameter for the hill.
Write the setHill() function, which should create, assign all subitems, and return a brand new Hill type variable based on the following inputs to the function (specifically in this order):
a char array of length 20 representing the name of the hill.
an int variable representing the x-location of the hill. an int variable representing the y-location of the hill. a double variable representing the height of the hill. a double variable representing the slope of the hill.
In main(), create and fill a Hill array of length 5 to store all of the data from the table above for the 5 hills on Innovation Do this by calling your setHill() function for each of the 5 hills. Of course, this requires the Hill struct to be properly defined.
In main(), define a 19x15 2D array to store elevations for Innovation Then, assign values to the array by calculating the elevation at each (x, y) location based on the summation formula above. You only need to consider integer x-values from 0-18 and integer y-values from 0-14, thus the 19x15 array of elevations. Make sure to sum up the elevation contribution from each of the 5 hills. Also, make sure to set all outer edges of the array to zero, representing the ocean. [It is important to realize that you are adding elevation at all (x, y) locations due to all 5 hills. So, the total elevation at the location of a hill peak will actually be greater than the height of that hill alone. For example, Hopper's Hill has a height of 15.0, but the total elevation at (14, 2) is 15.7288 with the extra 0.7288 due to contributions from the other 4 hills.]
Print out the 2D array of elevations for Innovation See the sample output below for the proper format. There are two key features:
the array should be printed in the same orientation as the map above, with the (0,
0) point in the lower left corner.
the format specifier "%4.1f " should be used to allocate 4 total characters for each floating-point value to 1 decimal place, followed by an additional space before the next value is printed.
Finally, in main(), let the user input an (x, y) location, and report back the elevation at that Do this by reading in two integers from the user. See the sample output below for proper formatting of the print statement of the elevation at the user's location. Additionally, let the user know whether or not their location is the peak of one of the hills. If so, let the user know which hill they are at the peak of. Again, make sure to properly format the output statements following the sample output given below. Finally, report the direction (North, East, South, or West) that a hiker should walk from the user- inputted (x,y) location with the least elevation change. That is, compare the squares directly adjacent and find the one with the minimal absolute difference in elevation from the user-inputted (x,y) location.
Sample Output
Here is a complete sample output from the code, where the user has entered their location as (12, 9):
Elevations for |
Innovation Island: |
|
|||||
0.0 0.0 0.0 |
0.0 0.0 0.0 0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
1.2 |
2.8 |
5.7 |
9.9 |
13.8 |
15.8 |
15.0 |
12.4 |
9.8 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|
6.0 |
7.1 |
8.0 |
8.1 |
7.3 |
5.4 |
3.3 |
1.7 |
0.0 |
|
|
|
|
|
|
|
0.0 |
6.8 |
11.6 |
16.1 |
18.0 |
16.3 |
12.0 |
7.6 |
4.7 |
3.6 |
3.7 |
4.6 |
6.2 |
8.2 |
8.8 |
6.7 |
3.6 |
1.5 |
0.0 |
|
|
|
|
|
|
|
0.0 |
7.5 |
12.9 |
18.0 |
20.0 |
18.0 |
13.2 |
7.9 |
4.3 |
2.5 |
2.3 |
3.3 |
6.4 |
11.1 |
13.3 |
10.3 |
5.1 |
1.7 |
0.0 |
|
|
|
|
|
|
|
0.0 |
6.7 |
11.6 |
16.1 |
18.0 |
16.1 |
11.7 |
6.9 |
3.5 |
1.7 |
1.4 |
2.5 |
6.5 |
12.6 |
15.7 |
12.2 |
5.9 |
1.8 |
0.0 |
|
|
|
|
|
|
|
0.0 |
4.9 |
8.4 |
11.6 |
12.9 |
11.6 |
8.4 |
4.9 |
2.4 |
1.1 |
0.8 |
1.6 |
4.7 |
9.4 12.0 |
9.3 |
4.4 |
1.3 |
0.0 |
|
|
|
|
|
|
|
|
0.0 0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
|
0.0 0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
|
|
|
|
|
|
|
Enter your x-location (1-17): 12
Enter your y-location (1-13): 9
The elevation for the point (12,9) is 20.0525 You are at the peak of Ada's Apex!
Walk West for a moderate hike. The elevation change is -1.0897
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme