finish this code: //Tax Withheld Calculator //input variables var salary =…
- User
finish this code: //Tax Withheld Calculator //input variables var salary = prompt(“Please enter your weekly salary before tax:”); var dependents = prompt(“How many dependents would you like to claim?”);
//calculations var provTax = salary * 0.06; var fedTax = salary * 0.25; var depDeduction = salary * (dependents * 0.02); var totalTax = provTax + fedTax - depDeduction; var finalSalary = salary - totalTax;
//output console.log(“Provincial tax withheld: $” + provTax.toFixed(2)); console.log("Federal tax withheld:
and put it in this template:
"use strict";
var readlineSync = require("readline-sync");
// DO NOT EDIT: The main function to house our program code function main() { //asks about your weekly salary and dependants var salary = readlineSync.question("enter your weekly salary before taxes:" );
}
// DO NOT EDIT: Trigger our main function to launch the program if (require.main === module) { main(); }
- Assistant
"use strict";
var readlineSync = require("readline-sync");
// DO NOT EDIT: The main function to house our program code function main() { //asks about your weekly salary and dependants var salary = readlineSync.question("Enter your weekly salary before taxes: "); var dependents = readlineSync.question("How many dependents would you like to claim? ");
//calculations var provTax = salary * 0.06; var fedTax = salary * 0.25; var depDeduction = salary * (dependents * 0.02); var totalTax = provTax + fedTax - depDeduction; var finalSalary = salary - totalTax; //output console.log("Provincial tax withheld: $" + provTax.toFixed(2)); console.log("Federal tax withheld: $" + fedTax.toFixed(2)); console.log("Dependents deduction: $" + depDeduction.toFixed(2)); console.log("Total tax withheld: $" + totalTax.toFixed(2)); console.log("Final salary after tax deductions: $" + finalSalary.toFixed(2));}
// DO NOT EDIT: Trigger our main function to launch the program if (require.main === module) { main(); }