Requirements:

The company that needed the flowchart and pseudocode for calculating a final price for has given you the responsibility of creating a program for that purpose.

The requirements remain the same as those indicated for the flowchart: the program will calculate the final price that a customer will pay for a product based on an initial price, membership on the Store Club and customer's state of residence. The company serves customers in New York and New Jersey. The components of the final price are the initial price, discount, shipping charge and tax.

The discount - 10% of the initial price - is given only to the members of the Store Club. The shipping charge is $5 for New Jersey customers and $3 for New York customers. The tax - applied to the sum of the discounted price plus shipping charge is 8% for New York customers and 7% for New Jersey customers. The output of the program will be the final price.

  • The formula to calculate the discount in dollars is: initial price x discount percent
  • The formula to calculate the final price is : (initial price - discount in dollars + shipping) x (1 + tax percent)

The company has also provided a video - attached to these instructions on Sakai that displays the way the program should work as well as the screen format when the program is run. (Note: on the video the program is run twice with two different data sets).

Additional Requirements:

  • You will enter a comment on the head section with your name on it.
  • You will utilize prompt() functions to request input from the customer.
  • You will utilize the alert() function to display your output as a clear and understandable message to the customer.
  • Variable names should be descriptive. For example, if a program is calculating the tip given at a restaurant, an appropriate variable name may be tipAmount.
  • The format of the screen should be similar to that provided on the video example.

Additional Information:

Since the content of a text box - which is what the prompt() function generates - is going to be used in mathematical operations, use the function parseInt() to ensure that the numeric input is treated as numeric data.

Syntax example:

numericVariable = parseInt(numericVariable)

To simplify the comparison of text data entered by the user, it is often easier to convert this text to upper case using the notation below.

Syntax example:

textVariable = textVariable.toUpperCase();

(See https://www.w3schools.com/jsref/jsref_toUpperCase.asp for additional example.)

Syntax example for prompt function:

var myName = prompt("Enter your name");

Syntax example for alert function:

alert("My name is + myName);
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.