Skip to content

Commit cbd95e5

Browse files
Update temperature.sh
1 parent 55c9e02 commit cbd95e5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

temperature.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,17 @@ temp_c=$(cat temps/region_C)
88

99
# Printing out the three variables
1010
echo "The three temperatures were $temp_a, $temp_b, and $temp_c"
11+
12+
13+
# An array with these variables as elements
14+
region_temps=($temp_b $temp_c)
15+
16+
# Calling an external program to get average temperature
17+
average_temp=$(echo "scale=2; (${temp_b[0]} + ${temp_c[0]}) / 2" | bc)
18+
19+
# Appending average temp to the array
20+
region_temps+=($average_temp)
21+
22+
# Printing out the whole array
23+
echo ${region_temps[@]}
24+

0 commit comments

Comments
 (0)