2014-06-16 47 views
-2

我正在爲一所學校的項目工作,我正在尋找爲什麼我的代碼無法運行的原因。我相信這是一件簡單的事,我沒有看到。任何幫助都會很棒。Javascript將無法運行

<!DOCTYPE HTML> 
<html> 
<head> 
    <script type="text/javascript"> 
    const TEN = 0.10; 
    const FIFTEEN = 0.15; 
    const TWENTYFIVE = 0.25; 
    const TWENTYEIGHT = 0.28; 
    const THRITYTHREE = 0.33; 
    const THIRTYFIVE = 0.35; 
    const THREENINETYSIX = 0.396; 


    function calculateTaxes(inTaxableIncome, inTaxRate) 
    { 
     var income = parseInt(inTaxableIncome); 
     var rate = parseFloat(inTaxRate); 
     var taxesOwed = income * rate; 
     return taxesOwed; 
    } 

    function refundOrPay(inTaxesOwed, inTaxesPaid) 
    { 
     var taxesOwed = parseInt(inTaxesOwed); 
     var taxesPaid = parseInt(inTaxesPaid); 
     var taxDifference = taxesOwed - taxesPaid; 
     return taxDifference; 
    }  

    </script> 
    </head> 
    <body> 
    <script type="text/javascript"> 
     document.writeln ("Welcome to COP 2500 Tax Service!<br>"); 

     //Determine the tax rate 
     var income = prompt ("Enter your year-end income"); 
     var deductions = prompt ("Enter your taxable deductions for the year", ""); 

     var taxableIncome = (parseInt (income) - parse Int (deductions)); 

     doument.writeln("Your taxable income is $" + taxableIncome + "<br>"); 
     var rate = getTaxRate(taxableIncome); 

     document.writeln("Based on a taxable income of $" + taxableIncome + " your tax rate is " + rate * 100 + " percent<br>") 

     var taxesOwed = calculateTaxes(taxableIncome, rate); 

     document.writeln("Your calculated taxes owed are $" + taxesOwed + "<br>"); 

     var taxesPaid = prompt("Enter the taxes you paid for the year", ""); 
     var taxResult = refundOrPay(taxesOwed, taxesPaid); 

     if(taxResult == 0) 
     { 
      document.writeln("Congratulations you broke even!<br>"); 
     } 
     else if(taxResult > 0) 
     { 
      document.writeln("Unfortunately you still owe more, please pay an additional $" + taxResult + " by April 15, 2014<br>"); 
     } 
     else 
     { 
      document.writeln("You overpaid your taxes, you will recieve a refund of $" + (-1 * taxresult) + "<br>"); 
     } 

     document.writeln("Thank you for using COP 2500 Tax Service!"); 
    </script> 
    </body> 
</html> 
+0

定義「不運行。 「應該發生什麼?會發生什麼呢?控制檯中顯示哪些錯誤? – JAAulde

+0

你得到了什麼錯誤?檢查控制檯。 –

+1

檢查控制檯是否有錯誤,例如這裏有一個:'parse Int(deductions)' - >'parseInt(deductions)',空間很重要。在這種情況下'document.writeln'也許不是最好的方法。 –

回答