Question

I need to make an online insurance calculator using basic HTML and Javascript. I need a...

I need to make an online insurance calculator using basic HTML and Javascript.

I need a form that allows a visitor to enter their age. Then, the visitor is to select (via radio buttons) an amount for their coverage rate (either 20,000, 30,000, 40,000, 50,000 or 60,000). Calculate the monthly premium according to the following info:

Age: 2 -18: $24 per $10,000 in coverage

Age: 19 - 40: $32 per $10,000 in coverage

Age: 41 – 65: $42 per $10,000 in coverage

Age: 66 - 70: $59 per $10,000 in coverage

For example, a 40 year old desiring $20,000 in coverage would pay $64 per month.

Display the resulting total on the page using innerHTML.

Homework Answers

Answer #1

Code:

<html>
   <body>
       <div>
       <form>

           <!-- Input age field-->
           Enter your age:<br><br><input id="age" type="text"><br><br>   

           <!-- Coverage rate options-->

           Select Coverage rate: <br><br>

               <input type="radio" id="coverage" name="coverage" value=20000>20000</option><br>

               <input type="radio" id="coverage" name="coverage" value=30000>30000</option><br>

               <input type="radio" id="coverage" name="coverage" value=40000>40000</option><br>

               <input type="radio" id="coverage" name="coverage" value=50000>50000</option><br>

           </select> <br><br>
          
           <!-- Input button onclicking this goto coverageFunction-->

           <input type="Button" value="Calculate Coverage Rate" onclick="calculateCoverage()">

       </form>
       </div>
       <div id="output"></div>
   </body>

   <script>
       function calculateCoverage()   {

               var age=parseInt(document.getElementById("age").value); //take input age from user

               var amounts = document.getElementsByName('coverage'); //take user selected coverage rate

               var amount;

               for(var i = 0; i < amounts.length; i++){

                   if(amounts[i].checked)

                       amount = parseInt(amounts[i].value);
                   }          
                  
               var premium_amount;

               if (age>=2 && age<=18) //based on age calculate premimum amount monthly

                   premium_amount=(amount/10000)*24;

               else if (age>=19 && age<=40)

                   premium_amount=(amount/10000)*32;

               else if (age>=41 && age<=65)

                   premium_amount=(amount/10000)*42;
               else if (age>=66 && age<=70)

                   premium_amount=(amount/10000)*59;

               document.getElementById("output").innerHTML="<br>Monthly Premimum amount is $" + premium_amount; //finally write the output

               }              
   </script>
</html>

Code and Output Screenshots:

Note: if you have any queries please post a comment thanks a lot..always available to help you...

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I need the java code for a 4-function calculator app on android studio. Please make sure...
I need the java code for a 4-function calculator app on android studio. Please make sure all the requirements shown below are followed (such as the error portion and etc). The topic of this app is to simply create a 4 function calculator which calculates math expressions (add, subtract, multiply, and divide numbers). The requirements are the following : - The only buttons needed are 0-9, *, /, +, -, a clear, and enter button - Implement the onclicklistener on...
6.12 LAB: Grade distribution In this lab, you will write a JavaScript program that generates a...
6.12 LAB: Grade distribution In this lab, you will write a JavaScript program that generates a bar graph of letter grades from a distributions of scores. Implement the parseScores function (1 point) Implement the parseScores function to take a space-separated string of scores as an argument and return an array of score strings. Each score is a number in the range [0, 100]. Ex: "45 78 98 83 86 99 90 59" → ["45","78","98","83","86","99","59"] Hint: JavaScript's string split() function can...
John, 38, makes $125,000 per year. He has a 35 year old wife, Nancy, and a...
John, 38, makes $125,000 per year. He has a 35 year old wife, Nancy, and a daughter who just turned 7. John’s share of the family’s consumption is 21%, and he pays an average tax rate of 28%. He plans to work another 30 years and expects salary increases equal to inflation, which he expects to be 3% annually. He expects to earn an 8% nominal rate of return on his investments. In the event of John’s death, Social Security...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT