Menu

Write Javascript Code Calculating Income Tax Using Else Else Statement Write Code Add Loop Q43893392

  • Write JavaScript code for calculating the income tax using if –else if – else statement.
  • Write code to add a loop that repeatedly calculates incometaxes for different taxable incomes until you enter 10000000 to aprompt window to stop it.
  • Not using $ sign and comma in the code
  • Need a prompt and alert window
  • Here’s my code
  • <script>
    var taxableIncome=0;
    var incomeTax;
    do {
    var taxableIncome = prompt(“Enter a valid taxable incomen” + “Orenter 10000000 to end tax calculator”);
      
    if (taxableIncome< 0) {
    alert(“Please enter a valid postive income”)
    }
    else if (taxableIncome>0 && taxableIncome<9700){
    incomeTax = (taxableIncome * 0.1);
    alert (“Your Income Tax is: ” + incomeTax);
    }
    else if (taxableIncome>9701 && taxableIncome<39475){
    incomeTax = 970 + (taxableIncome – 9700)* 0.12;
    alert (“Your Income Tax is: ” + incomeTax);
    }
    else if (taxableIncome>39476 && taxableIncome<84200){
    incomeTax = 4543 + (taxableIncome – 39475)* 0.22;
    alert (“Your Income Tax is: ” + incomeTax);
    }
    else if (taxableIncome>84201 && taxableIncome<160725){
    incomeTax = 14382 + (taxableIncome – 84200)* 0.24;
    alert (“Your Income Tax is: ” + incomeTax);
    }
    else if (taxableIncome>160726 &&taxableIncome<204100) {
    incomeTax = 32748 + (taxableIncome – 160725)* 0.32;
    alert (“Your Income Tax is: ” + incomeTax);
    }
    else if (taxableIncome>204101 &&taxableIncome<510300) {
    incomeTax = 46628 + (taxableIncome – 204100)* 0.35;
    alert (“Your Income Tax is: ” + incomeTax);
    }
    else if (taxableIncome>510301){
    incomeTax = 153798 + (taxableIncome – 510300)* 0.37;
    alert (“Your Income Tax is: ” + incomeTax);
    }
    else
    alert (“Your Income Tax is: ” + incomeTax);
    }
    while(taxableIncome != 10000000)
       </script>
  • I still have a problem to end the loop, and could anyone helpme to simplfy my code as well.

Expert Answer


Answer to Write JavaScript code for calculating the income tax using if – else if – else statement. Write code to add a loop …

OR