-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.js
More file actions
85 lines (81 loc) · 2.51 KB
/
calculator.js
File metadata and controls
85 lines (81 loc) · 2.51 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
function calculateAmt(c,s){
var c = document.getElementById('i_calls').value
if(c==""){
alert("Please fill all the fields");
document.myForm.calls.focus();
return false;
}
var s = document.getElementById('i_sms').value
if(s==""){
alert("Please fill all the fields");
document.myForm.sms.focus();
return false;
}
var msg1=" ";
var msg2=" ";
var costis1;
var cost;
var d = calls(c);
var e = smsmsg(s);
addcallsms(c,s);
function calls(c){
if(c<=50){
var costis = (c*0.50);
costis1=parseFloat(costis).toFixed(2);
msg1= "Charges for Call : "+costis1+"/-";
return costis1;
}
else if(c<=150){
var costis=((50*0.50) + (c-50)*0.70) ;
costis1=parseFloat(costis).toFixed(2);
msg1=("Charges for Call : "+costis1+"/-");
return costis1;
}
else if(c<=300){
var costis=((50*0.50) + (100*0.70) + (c-150)*0.85);
costis1=parseFloat(costis).toFixed(2);
msg1=("Charges for Call : "+costis1+"/-");
return costis1;
}
else{
var costis=((50*0.50) + (100*0.75) + (150*0.85) + (c-300)*0.95);
costis1=parseFloat(costis).toFixed(2);
msg1=("Charges for Call : "+costis1+"/-");
return costis1;
}
}
function smsmsg(s){
if(s<=50){
var cost=0;
cost=parseFloat(cost).toFixed(2);
msg2=("Charges for SMS : "+cost+"/-");
return cost;
}
else if(s<=200){
var cost= (s-50)*0.25;
cost=parseFloat(cost).toFixed(2);
msg2=("Charges for SMS : "+cost+"/-");
return cost;
}
else if(s<=400){
var cost= ((150)*0.25 + (s-200)*0.40);
cost=parseFloat(cost).toFixed(2);
msg2=("Charges for SMS : "+cost+"/-");
return cost;
}
else{
var cost= ((150)*0.25 + (200)*0.40 + (s-400)*0.45);
cost=parseFloat(cost).toFixed(2);
msg2=("Charges for SMS : "+cost+"/-");
return cost;
}
}
function addcallsms(c,s){
d=parseFloat(d);
e=parseFloat(e);
var add= d+e;
alert(msg1 + "\n"+msg2 + "\nTotal Charges : "+add+"/-");
return true;
}
return true;
}