-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSumAver.html
More file actions
46 lines (44 loc) · 1.35 KB
/
Copy pathSumAver.html
File metadata and controls
46 lines (44 loc) · 1.35 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JishnuSum</title>
</head>
<body>
<h2>Welcome to Sum and Average WebPage version j.1</h2>
<input type="button" onclick="action()" value="Click Me">
<script>
function action(){
let sum = 0;
let flg = 1, n;
do{
n = Number(prompt("Enter Number of Inputs: "));
if(n > 0 && !isNaN(n)) flg = 0;
if(flg) alert("Length should be a Positive Integer")
}while(flg);
for(let i=0; i < n; i++) {
let x = Number(prompt("Enter number to Add : "));
if(isNaN(x)){
alert("This is not a Number")
i--;
}
else if((x%10)){
alert("This number is not terminated by zero");
i--;
}
else if(x <= 0){
prompt("This Number is Not a Positive Number");
i--;
}
else{
sum += x;
}
}
let av = sum/n;
alert("Sum is : " + sum + "\n");
alert("Average is : " + av + "\n");
}
</script>
</body>
</html>