Saved Bookmarks
| 1. |
Write the code to display a form as shown below along with the javascript code to achieve the specified task. User should be able to enter the number of calls and the total amount payable gets displayed when he presses “calculate” button.The total amount payable will be calculated based on the following rate list:Rs. 1.00 per call for the 1st 100 callsRs. 1.20 per call for the next 100 callsRs. 1.50 per call for the next 50 callsRs. 2.00 per call for more than 250 calls |
|
Answer» <html> <head> <SCRIPT language="javascript"> function calc() { var consm, amount=0; consm=document.form1.f1.value; if(consm<=100) amount=consm*1.0 else if(consm<=200) amount=100+1.2*(consm-100) else if(consm<=250) amount=100+1.2*100+1.5*(consm-200) else amount=100+ 1.2*100 + 1.5*50 +2.0 *(consm-250) document.write("amount payable is " + amount); } </SCRIPT> </head> <body> <form name="form1"> NUMBER OF CALLS <input name=f1 type=text> <br> <input type=button name=b1 onclick=calc() value=CALCULATE BILL> </form> </body> </html> |
|