Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

HINF 115 A01 & A02  Programming for Healthcare

Activity 5: Javascript Calculations, Pills for Bills

Issued: Thursday, October 12, 2023

Assignment Due: Wednesday, October 18, 2023 by 11:59pm

Objectives

The main objective of this easy assignment is to get you familiar with JavaScript.

This time the code is more structured and complex.

Scenario

A patient is issued a prescription. We have an automated“pills-for-bills” ma-

chine that accepts cash in bills. Patient presents health card, feeds in cash.  In

return they receive pills and their change. You get to crunch the numbers for

the display mounted in the machine’spanel.

Setup

There are two files you need to begin this activity. They both are zipped

up into HINF-115-Activity-5.zip which you can find in the assignment

directory. The files are as follows:

1.  The index.html contains a new version of the page you worked on previously. It contains a link to the second file:

2.  calculator.html which is where you need to do your work.

Create a new folder in your HINF115 folder and name it Activity 5 then un- zip the files in to Activity 5.

The Exercises

Exercise 1 Calculate and store the cost for the pills

a.  Create a new variable named  pillCost .

b.  Set its value to be the product of pill count and pill price.

c.  Get the values of pill count and pill price by calling the appropriate helper functions.

d.  Dump the value of  pillCost in the console so you can see what’s go- ing on. To do this, uncomment the line below in calculator.html — after you’ve done (1a) and (1b):

console.log("pillCost: " + pillCost);

e.  Open your devtools console to see the message.

Exercise 2 Calculate and store the pre-tax cost

a.  Create a new variable named  preTaxCost .

b.  Set its value to be the sum of  pillCost and Dispensing Fees.

c.  Do not recalculate  pillCost, use the  pillCost variable you made

earlier.

d.  Call the appropriate helper function for the Dispensing Fees.

e.  Dump the value of preTaxCost in the console the same way as in Exer-

cise 1.

Exercise 3 Calculate and store the tax payable

a.  Create a new variable named  tax.

b.  Set its value to be the product of the tax rate and the pre-tax cost.

c.  Do not recalculate the pre tax cost, use the  preTaxCost variable you

made earlier.

d.  Dump the value of tax in the console the same way as inStep 1.

Exercise 4 Calculate and store the tax payable

a.  Compute the total cost and store it the existing variable named  totalCost .

b.  The total cost is the sum of the  preTaxCost and the tax.

c.  Dump the total cost to the console.

Exercise 5 Change the UI to restict the user’s choice to bill values only

In the HTML, change the “cash amount”  <input> field element into a  <select> element with dollar-bill amounts as options.  In other words, restrict users so that they only have options to pay with $5, $10, $20, $50, or $100 bills.

Submitting your work

Use the Activity 5. Javascript Calculations, Pills for Bills assignment on Brightspace to submit your work. You must submit two items:

1.  Screenshot(s) of your code running in a browser.

2.  Your code packaged up as a zipfile.

Notes

•  If you’reworking in a group, only one member needs to submit the as- signment.

•  Alert: There is an issue on Brightspace (BS) where submitting HTML

files causes BS to interpret your submission as formatted text, i.e., an

essay. To avoid this issue, put all your files into a zipfile and submit one file.

This assignment is due Wednesday, October 18, 2023 by 11:59pm.