-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
246 lines (203 loc) · 7.27 KB
/
script.js
File metadata and controls
246 lines (203 loc) · 7.27 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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
function absol() {
var ad = document.getElementById('ad');
var first = document.getElementById('first').value;
var second = document.getElementById('second').value;
var sed = document.getElementById('secondDiv');
var tot = Math.abs(first);
ad.innerText = tot;
}
function percent() {
var ad = document.getElementById('ad');
var first = document.getElementById('first').value;
var second = document.getElementById('second').value;
var sed = document.getElementById('secondDiv');
if(first.includes('.')) {
var tot = first*100;
} else {
var tot = first;
}
ad.innerText = tot;
}
function exposeOptD() {
var ad = document.getElementById('ad2');
var s = ad.style.display;
if(s = "none") {
s = "block";
} else {
s = "none";
}
}
function mod() {
var ad = document.getElementById('ad');
var first = document.getElementById('first').value;
var second = document.getElementById('second').value;
var tot = first % second;
if(isNaN(tot) == true) {
ad.innerText = "Please enter values.";
} else {
ad.innerText = first + " % " + second + " is " + tot;
}
}
function random() {
var ad = document.getElementById('ad');
var tot = Math.floor( Math.random() * 10000);
ad.innerText = tot;
}
function analyzePoints() {
document.getElementById('points').submit;
document.getElementById('questions').submit;
var points = document.getElementById('points').value;
var questions = document.getElementById('questions').value;
var ad = document.getElementById('ad');
var total = Math.round(points/questions);
if(total <= 0 || points <= 0 || questions <= 0) {
ad.innerHTML = "Really?";
}
else {
if(total > 1) {
ad.innerHTML = "Each question in your assessment is about " + total + " points.";
}
if(total === 1) {
ad.innerText = "Each question in your assessment is " + total + " point.";
} else {
ad.innerText = "Each question in your assessment is " + total + " points.";
return false;
}
return false;
}
}
function doExp() {
var first = document.getElementById('first').value;
var second = document.getElementById('second').value;
var ad = document.getElementById('ad');
var tot = Math.pow(first, second);
if(first === null) {
first = 0;
}
if(second === null) {
second = 0;
}
if(isNaN(tot) == true) {
ad.innerText = "Please enter a value.";
}
if(tot === 0) {
ad.innerText = "Please enter values.";
}
else {
ad.innerText = first + " to the power of " + second + " is " + tot + ".";
return false;
}
}
function findSum() {
document.getElementById('first').submit;
document.getElementById('second').submit;
var first = document.getElementById('first').value;
var second = document.getElementById('second').value;
var ad = document.getElementById('ad');
if(first.includes('.') || second.includes('.')) {
var sum = parseFloat(first) + parseFloat(second);
} else {
var sum = parseInt(first,10) + parseInt(second,10);
}
if(first === null) {
first = 0;
}
if(second === null) {
second = 0;
}
if(isNaN(sum) == true) {
ad.innerHTML = "Please enter a <i>numerical</i> value."
} else {
ad.innerHTML = "The sum of " + first + " and " + second + " is " + sum + ".";
}
}
function remainder() {
var first = document.getElementById('first').value;
var second = document.getElementById('second').value;
var ad = document.getElementById('ad');
var quotient = first/second;
var reman = first % second;
var remainder = Math.floor(reman);
var floored = Math.floor(quotient);
if(isNaN(floored) == true || isNaN(remainder) == true) {
ad.innerHTML = 'Please enter values in the two number fields.';
setTimeout(function() {window.location.reload();}, 1000000);
} else {
if(remainder === 0) {
ad.innerText = 'The answer is ' + floored + '.';
} else {
ad.innerHTML = 'The answer is ' + floored + ' R' + remainder + '.';
}
}
}
function divide() {
var first = document.getElementById('first').value;
var second = document.getElementById('second').value;
var ad = document.getElementById('ad');
var quotient = first/second;
if(isNaN(quotient) == true) {
ad.innerHTML = 'Please enter values in the two number fields.';
setTimeout(function() {window.location.reload();}, 1000000);
} else {
ad.innerHTML = 'The answer is ' + quotient + '.';
}
}
function multiply() {
document.getElementById('first').submit;
document.getElementById('second').submit;
var first = document.getElementById('first').value;
var second = document.getElementById('second').value;
var ad = document.getElementById('ad');
var product = first*second;
var productR = Math.round(product);
if(product == 0) {
ad.innerHTML = "You can probably figure that out yourself.";
} else {
ad.innerHTML = 'The product is ' + productR + '.';
return false;
}
}
function cube() {
document.getElementById('square').submit;
var ad = document.getElementById('ad');
var valve = document.getElementById('square').value;
var tot = valve*valve*valve;
if(valve === null) {
ad.innerHTML = "Please enter a value.";
} else {
ad.innerHTML = valve + " cubed is " + tot + ".";
}
}
function square() {
document.getElementById('square').submit;
var ad = document.getElementById('ad');
var valve = document.getElementById('square').value;
var tot = valve*valve;
if(valve === null) {
ad.innerHTML = "Please enter a value.";
} else {
ad.innerHTML = valve + " squared is " + tot + ".";
}
}
function findDiff() {
document.getElementById('first').submit;
document.getElementById('second').submit;
var first = document.getElementById('first').value;
var second = document.getElementById('second').value;
var ad = document.getElementById('ad');
if(first === null) {
ad.innerText = "That\'s not too hard.";
first = 0;
}
if(second === null) {
ad.innerText = "That\'s not too hard.";
second = 0;
}
var diff = first - second;
console.log(diff);
if(first == 0 || second == 0) {
ad.innerHTML = 'Please enter values in the input fields.';
} else {
ad.innerHTML = first + " - " + second + " = " + diff + ".";
}
}