JavaScript :- Electricity Bill (if...else if)

Hello Friends..!!

This is JavaScript Practical :- Electricity Bill (if...else if).
Script written in small letter because JavaScript Case Sensitive.

Script:-

<html>
<head>
<title>Electicity Bill</title>
</head>
<body>
<script type="text/javascript">
// this is a electicity bill.
var unit,amt=0,price=0;
unit=parseInt(prompt("Enter unit"));
if(unit >=500)
{
amt=unit*10;
document.write("Amount of Electicity bill = ",amt);
}
else if(unit >= 400 && unit <= 499)
{
amt=unit*8;
document.write("Amount of Electicity bill = ",amt);
}
else if (unit >= 300 && unit <= 399)
{
amt=unit*7;
document.write("Amount of Electicity bill = ",amt);
}
else if (unit >= 200 && unit <= 299)
{
amt=unit*price;
document.write("Amount of Electicity bill = ",amt);
}
else if (unit >= 100 && unit <= 199)
{
amt=unit*6;
document.write("Amount of Electicity bill = ",amt);
}
else
{
amt=unit*5;
document.write("Amount of Electicity bill = ",amt);
}
</script>
</body>
</html>

Save the File .html

Output:-




If you have any doubts mention on the Comment Box.


Please follow the my Blog, Share and Comment.

Comments

Popular posts from this blog

What is Website