Skip to content

Commit 66c66a5

Browse files
committed
tip calulator modified
1 parent 90e128f commit 66c66a5

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Projects/Tip Calculator/script.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,38 @@ function calculateTotal() {
1111
const billValue = billInput.value;
1212
const tipValue = tipInput.value;
1313
const splitValue = splitInput.value;
14+
if(billValue<0 && tipValue<0 && splitValue<0)
15+
{
16+
alert("Invalid : Please Enter positive bill amount , tip percentage and split value!");
17+
return;
18+
}
19+
if(billValue<0 && tipValue<0)
20+
{
21+
alert("Invalid : Please enter positive bill amount and tip percentage!");
22+
return;
23+
}
24+
if(billValue<0 && splitValue<0)
25+
{
26+
alert("Invalid : Please enter positive bill amount and split value!");
27+
return;
28+
}
29+
if(splitValue<0 && tipValue<0)
30+
{
31+
alert("Invalid : Please enter positive tip percentage and split value!");
32+
return;
33+
}
34+
if(billValue<0){
35+
alert("Invalid : Please enter positive bill amount!");
36+
return;
37+
}
38+
if(tipValue<0){
39+
alert("Invalid : Please enter positive tip percentage!");
40+
return;
41+
}
42+
if(splitValue<0){
43+
alert("Invalid : Please enter positive split value!");
44+
return;
45+
}
1446

1547
const tipAmount = billValue * (tipValue / 100);
1648
const totalValue = parseFloat(billValue) + tipAmount;

0 commit comments

Comments
 (0)