Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
69 lines (53 loc) · 2.19 KB
/
Copy pathscript.js
File metadata and controls
69 lines (53 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* Step 1: Growing Pains
/* The area in which the plants are contained is circular, with a radius of 5 meters.
The formula for calculating the area of a circle is PI multiplied by the radius, squared:
const PI = 3.1415;
const area = PI * radius * radius;
Each plant requires a minimum space of 0.8 square meters.
The area is starting with 20 plants.
The plants double in number every week.*/
/* Predict the plant growth after a specific number of weeks.
Implement control flow to make decisions on whether the plants should be:
Pruned, to stop them from exceeding the capacity of the garden.
This condition should be met if the plant count after the given number of weeks is greater than 80%
of the maximum capacity of the garden.
Monitored, if they are growing at an acceptable rate.
This condition should be met if the plant count is between 50% and 80% of the maximum capacity of
the garden after the given number of weeks.
Planted, if there is room to plant more plants.
This condition should be met if the plant count after the given
number of weeks is less than 50% of the maximum capacity of the garden.
Within your submission, include the results for 1, 2, and 3 weeks of growth as inputs.*/
/* Provided info:
- circular area w/ plants, radius of 5
- cal. area of circle= PI * radius * radius
- plants double in size weekly
- pruned: ___ weeks & plant count < 80%
- monitored: ___ weeks & plant count between 50% - 80% of max. cap
- planted: ___ weeks & plant count > 50%
- growth inputs for weeks: 1, 2, 3
* monitor growth of plants / decide on prune, monitor, or plant*
const PI = 3.1415;
const radius = 5
*/
const PI = 3.1415;
const radius = 5;
const plantSpace = 0.8;
const gardenArea = PI * radius * radius
/* console.log(gardenArea);
78.53750000000001 */
/* number of max plants garden can hold */
const maxPlants = gardenArea / plantSpace;
/* console.log(maxPlants);
98.171875 */
/* gardenArea = 78.53750000000001
maxPlants = 98.171875 */
const startingPlants = 20;
const weeks = 3;
let currentPlants = startingPlants;
for (let i = 0; i < weeks; i++) {
currentPlants *= 2;
}
console.log(`There will be ${currentPlants} after ${weeks}.`);
/* There will be 160 after 3. */
/* Part 2: Thinking Bigger */