Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer the following question based on the C programming language Question 3 (15 marks) Timber Regrowth A challenge in timber management is to determine
Please answer the following question based on the C programming language
Question 3 (15 marks) Timber Regrowth A challenge in timber management is to determine how many acres to leave uncut after harvesting in a forest so that the harvested area is reforested in a certain period of time. It is assumed that reforestation take place at a known constant rate, r, per year, depending on climate and soil conditions. A reforestation equation expresses this growth as a function of the amount of timber standing and the reforestation rate 1 where i represents the year, 0 after harvesting is completed, and 1, 2, 3 represents the number of years after harvesting (thus represents the acres uncut after harvesting is completed, and 41,A2, 43, represents the reforested acres after years 1,2,3, ...) r is the reforestation rate expressed as a fraction (for example 0.05 means that the forested acres are increases by 5% at the end of a year) You are responsible for developing a software tool that supports analysis of reforestation. Given (from the user) a minimum value for acres uncut, * . and reforestation rate, show a table in the console that increments the values of uncut acres (from the given minimum to the maximum values) and for each of these values the total number of years it takes to totally restore the forest. The table shall contain 20 rows. The following shows a sample interaction with the user ser forestation rate: Num Years For Total Reforestation 1Sp you want to quit (y Complete the project using the following guidelines o Define a structure type, FOREST, that contains 5 members, an array to store the name of the forest, and 4 members to store the data values obtained from the user (see the above list) Use symbolic constants to eliminate magic numbers in your program o Declares a structure variable of type FOREST and one or two arrays for storing table data. Use a loop to repeat the process (get user input, fill in the table data and print a table) until the o o o This function shall call three functions to 1) get user input, 2) fill in the table data, and 3) display * Function getForestInput o o This function uses a pointer to fill in the structure variable declared in main. Data input by the user must be checked so that All real values must be greater than 0.0 (use the function getPositiveValue from lab 5) The maximum uncut acres must be less than the total acres of the forest. The minimum uncut acres must be less than the maximum uncut acres * - " " The reforestation rate must be between 0 and 1 (exclusive, i.e. cannot be 0 or 1) Function calculateTableData The parameters of this function consist of a pointer to a structure variable of type FOREST and the necessary parameters to access and update the arrays declared in the function main. Do not use symbolic constants for the dimensions of the arrays, but parameters (this makes the function general to handle arrays of any dimension) In addition to a loop to pass through the array (or arrays), use a nested loop to compute the number of vears for total reforestation for a given value of uncut acres o o Function displayTable The parameters of this function consist of a pointer to a structure variable of type FOREST and the necessary parameters to access and update the arrays declared in the function main. Do not use symbolic constants for the dimensions of the arrays, but parameters (this makes the function general to handle arrays of any dimension) o o This function first displays the forest information (see the sample output) o It then displays the contents of the array(s) in table form. o Please respect the output format such as the number of digits in the fraction part of the real numbers To answer this question, please provide 1) The source code of your program (DO NOT insert the source code into your assignment document, PDF file) Insert the output for the test cases shown in the table on the next page into your assignment document Also show an output that shows how invalid input data is treated. 2) The following table gives the output for three tests cases (i.e. three ranges of time). The tables were computed using and Excel program (see the file GNG1106A5TestCases.xlsx) Name Total Acres Uncut Acres Min Uncut Acres Max Reforestation Rate ncr Forest 1 Forest 2 Forest 3 15000 300 5000 0.05 247.37 22676 1000 10000 0.10 473.68 58732 5000 20000 0.15 789.47 Uncut Acres Years to Uncut Years to Uncut reforest Acres Years to reforest Acres 1300.00 2 547.37 3 794.74 41042.11 5 1289.47 6 1536.84 71784.21 82031.58 9 2278.95 102526.32 112773.68 123021.05 133268 42 143515.79 15 3763.16 16 4010.53 17 4257.89 184505.26 194752.63 20 5000.00 81 1000.00 68 1473.68 61 1947.37 55 2421.05 51 2894.74 47 3368.42 443842.11 414315.79 39 4789.47 37 5263.16 35 5736.84 33 6210.53 32 6684.21 30 7157.89 29 7631.58 288105.26 26 8578.95 25 9052.63 24 9526.32 23 10000.00 33 5000.00 295789.47 266578.95 24 7368.42 22 8157.89 218947.37 19 9736.84 18 10526.32 17 11315.79 16 12105.26 15 12894.74 14 13684.21 13 14473.68 13 15263.16 12 16052.63 1116842.11 1117631.58 10 18421.05 10 19210.53 9 20000.00 17 16 15 14 10 10Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started