Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a function declaration called calculateTax() that takes a dollar amount as a parameter and calculates the tax. a. If the amount is less

1. Create a function declaration called calculateTax() that takes a dollar amount as a parameter and calculates the tax.

a. If the amount is less than or equal to $5.00, apply 20% tax. If the amount is greater than or equal to $5.01 and less than or equal to $100, apply 15% tax. If the amount is $100.01 or more, apply 5% tax. Add the tax amount to the original amount and return the new total.

b. Ensure that you round the final amount to 2 decimal places and return it as a Number type, not string.

c. This function should be 'pure' in that it should only return a simple value.

d. If the user tries to pass in a non-numeric value, return the string "invalid", as a string type.

e. Create another function declaration called formatMoney() that takes two parameters. The first parameter should be the dollar amount to format. The second parameter will be a boolean value whereby, if true, would see the dollar amount formatted with commas (,) separating the thousands - like $2,344.33. If the flag is false, do not include the commas in the formatted values. The programmer (you) will set the boolean flag, not the user.

f. Use a prompt() to gather the initial dollar amount from the user and then pass that value into your calcTax function. Take the return of that function and pass it to your formatMoney() function. The returned, properly taxed, properly formatted value, should appear in an alert() box. Save all of this work in a js file called taxMoney.js. Please attach it to a properly formatted HTML page called taxIt.html.

g. Code for all above is commented - header and inline - functions are well commented.

h. Code for all above is properly aligned and nested, braces are aligned. Variables and page names are named appropriately and lowerCamelCasing is observed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxxviii Special Issue On Database And Expert Systems Applications Lncs 11250

Authors: Abdelkader Hameurlain ,Roland Wagner ,Sven Hartmann ,Hui Ma

1st Edition

3662583836, 978-3662583838

More Books

Students also viewed these Databases questions

Question

How to solve maths problems with examples

Answered: 1 week ago

Question

Explain Coulomb's law with an example

Answered: 1 week ago

Question

What is operating system?

Answered: 1 week ago