write me a script using only var and basic calculation, following these instructions:…
- User
write me a script using only var and basic calculation, following these instructions: Tax Withheld Calculator Write a console program that calculates the total amount of tax withheld from an employee’s weekly salary. The total withheld tax amount is calculated by combining the amount of provincial tax withheld and the amount of federal tax withheld, minus a per-dependent deduction from the total tax withheld. The user will enter their pre-tax weekly salary amount and the number of dependents they wish to claim. The program will calculate and output the amount of provincial tax withheld, amount of federal tax withheld, the dependent tax deduction, and the user’s final take-home amount. Provincial withholding tax is calculated at 6.0%. Federal withholding tax is calculated at 25.0%. The tax deduction for dependents is calculated at 2.0% of the employee’s salary per dependent.
- Assistant
var preTaxSalary = prompt("What is your pre-tax weekly salary amount?"); var dependents = prompt("How many dependents do you wish to claim?");
var provTaxWithheld = (preTaxSalary * 0.06).toFixed(2); var fedTaxWithheld = (preTaxSalary * 0.25).toFixed(2); var dependentDeduction = (preTaxSalary * 0.02 * dependents).toFixed(2);
var totalTaxWithheld = (parseFloat(provTaxWithheld) + parseFloat(fedTaxWithheld) - parseFloat(dependentDeduction)).toFixed(2);
var takeHomeAmount = (preTaxSalary - totalTaxWithheld).toFixed(2);
console.log("Provincial Tax Withheld: " + fedTaxWithheld); console.log("Dependent Tax Deduction: " + totalTaxWithheld); console.log("Take-Home Amount: $" + takeHomeAmount);
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.