This repository has been archived by the owner on May 11, 2021. It is now read-only.
/
estimation_with_decimals.html
99 lines (95 loc) · 4.83 KB
/
estimation_with_decimals.html
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<html data-require="math math-format word-problems stat">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Estimation with decimals</title>
<script data-main="../local-only/main.js" src="../local-only/require.js"></script>
</head>
<body>
<div class="exercise">
<div class="problems">
<div>
<div class="vars">
<var id="VALUES">_.map(
randRange(1000, 16000, randRange(3, 7)),
function( n ) {
var x = n / 1000;
var precision = randRange(1, 2);
return [roundTo(precision, x), precision];
})</var>
<var id="ANSWER">sum($.map(VALUES, function(pair) {
return round(pair[0]);
}))</var>
<var id="TYPES">randFromArray([
["jogging", "ran", new Plural(function(n) {
return $.ngettext("mile", "miles", n);
})],
["riding a bicycle", "traveled", new Plural(function(n) {
return $.ngettext("mile", "miles", n);
})],
["collecting mushrooms", "collected", new Plural(function(n) {
return $.ngettext("pound", "pounds", n);
})],
["painting a roof", "painted", new Plural(function(n) {
return $.ngettext("square foot", "square feet", n);
})],
["harvesting grain", "harvested", new Plural(function(n) {
return $.ngettext("tonne", "tonnes", n);
})]
])</var>
<var id="ACC">0</var>
<var id="SUM">
(function() {
var sum = 0;
$.each(VALUES, function(i, pair) {
sum += roundTo(pair[1], pair[0]);
});
return roundTo(2, sum);
})()
</var>
</div>
<p>
<var>person(1)</var> has been <var>TYPES[0]</var> every day for the last <code><var>VALUES.length</var></code> days.
<span data-if="isMale(1)">The table below shows the amount he <var>TYPES[1]</var> in <var>plural_form(TYPES[2])</var> each day.</span>
<span data-else="">The table below shows the amount she <var>TYPES[1]</var> in <var>plural_form(TYPES[2])</var> each day.</span>
</p>
<p class="question" data-if="isMale(1)">
Estimate how much he <var>TYPES[1]</var> in total by first rounding each amount to the nearest whole number and then summing all the rounded amounts.
</p><p class="question" data-else="">
Estimate how much she <var>TYPES[1]</var> in total by first rounding each amount to the nearest whole number and then summing all the rounded amounts.
</p>
<p>
Note that if you sum the exact amounts (<code><var>localeToFixed(SUM, 2)</var></code>) and then round, you'll get <code><var>round(SUM)</var></code>. For fun, pay attention to how this number compares with your estimate.
</p>
<div class="fake_header estimation">
<span>Day<br> <span style="color:white">" "</span></span>
<span>Amount <br><font size="2">(in <var>plural_form(TYPES[2])</var>)</font></span>
</div>
<div class="fake_row estimation" data-each="VALUES as i, pair">
<span><var>i+1</var></span>
<span><var>localeToFixed(pair[0], pair[1])</var></span>
</div>
<p class="solution" data-type="multiple">
<span class="sol" data-forms="integer"><var>ANSWER</var></span> <var>plural_form(TYPES[2], ANSWER)</var>
</p>
<div class="hints">
<p>Round all the numbers to the nearest <var>plural_form(TYPES[2], 1)</var> and add them up.</p>
<div class="fake_header estimation">
<span>Day</span>
<span>Amount</span>
<span>Rounded</span>
<span>Running total</span>
</div>
<div class="fake_row estimation" data-each="VALUES as i, pair">
<span><var>i+1</var></span>
<span><var>localeToFixed(pair[0], pair[1])</var></span>
<span><var>round(pair[0])</var></span>
<span><var>ACC += round(pair[0])</var></span>
</div>
<p>Therefore the estimate is <code><var>ANSWER</var></code> <var>plural_form(TYPES[2], ANSWER)</var>.</p>
</div>
</div>
</div>
</div>
</body>
</html>