Answered You can hire a professional tutor to get the answer.

QUESTION

The first line is the header file, describing each field. Each field is separated by a tab. The first column is the site number(siteNo, integer).

The first line is the header file, describing each field. Each field is separated by a tab. The first column is the site number(siteNo, integer). The second column is the site code(siteCode, string). Third and fourth column are the X and Y coordinatesof the location of the site, on a 50x50 grid. They takeinteger values between 0 and 49. Fifth column is the initial cost of site exploration. Sixth column is the yearly cost of site maintenance. The last column is whether the site is found feasiblefor a specific function after initial inspection. It takesvalues ‘Y’ and ‘N’.Write a main function that will call and test all thefunctions below:1. (15 points) Create an appropriate struct type for storing the information for each site, calling it siteType. Write afunction that reads the information from the file and stores it in an array of siteType.E.g. const int numSites=21; siteType sites[numsites];Note: files can only be passed as reference variables;2. (10 points) Write a function that prints all the data on the screen organized similar to how it looks on the file.3. (15 points) Write a function that sorts the data using Selection Sort based on the value of InitialCost. On the mainfunction, print the sorted list on screen.4. (15 points) If two sites S1 and S2 have coordinates (x1, y1) and (x2, y2) respectively, then the physical distancebetween S1 and S2 is given by √(????1 − ????2)2 + (????1 − ????2)2. Define a two dimensional array of doubles, D.Write a function that fills out D, such that D[i][j] is the distance between sites i and j for all the sites i,j. On themain function, print the array on screen.5. (15 points) Write a function that for each site, calculates the average distance from the other sites (i.e., row orcolumn average of D). Find the site that is closest to all the other sites. On the main function, print for each site:the siteCode and the average distance. Also print the site that is closest to all.6. (15 points) Write a function that returns the number of feasible sites within a radius R of the center point(25,25). On the main code print out the number of site for R=5, 10, 25.7. (15 points) Plot the sites on a 50x50 grid. I.e. for site with coordinates (i, j) print ‘Y’ or ‘N’ (depending if it isfeasible or not) on the i-th row and j-th column. Hint: create a char map[50][50] where map[i][j]= ‘Y’ if (i, j) arecoordinates of a feasible site; map[i][j]= ‘N’ if (i, j) are coordinates of a infeasible site, and map[i][j]=’ ‘ otherwise.Then all you have to do is print map on the screenSiteNo siteCode X Y InitialCost YearlyCost Feasible(Y/N)1 S50x50_100 43 29 2941.26 5221.26 Y2 S50x50_101 28 32 1809.85 2397.08 Y3 S50x50_102 28 9 2235.46 3190.19 Y4 S50x50_103 42 46 9921.38 5562.34 N5 S50x50_104 21 25 6166.89 2264.09 N6 S50x50_105 38 44 4067.08 4649.23 N7 S50x50_106 48 22 6414.69 5153.49 Y8 S50x50_107 38 22 7373.52 5767.38 N9 S50x50_108 15 47 5505.13 6427.38 Y10 S50x50_109 45 32 4228.61 8155.92 N11 S50x50_110 37 18 2030.47 8616.05 Y12 S50x50_111 1 15 7194.42 9220.12 Y13 S50x50_112 39 28 5224.06 991.68 N14 S50x50_113 38 22 1541.70 784.84 N15 S50x50_114 47 0 9007.99 421.71 N16 S50x50_115 45 46 5860.82 3307.79 Y17 S50x50_116 20 49 1013.28 5452.12 Y18 S50x50_117 23 39 8658.35 4204.38 Y19 S50x50_118 40 34 9944.57 1078.34 Y20 S50x50_119 39 11 5423.99 9507.67 N21 S50x50_120 49 21 7055.35 7518.34 N

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question