Question: A . [ Worth 1 3 points ] Function program 1 ( ) . When button with the label problem 1 is clicked, the

A.[Worth 13 points] Function program1(). When button with the label "problem 1" is clicked,
the function program1() should be called in your JS file. This method should call a recursive
helper function with logic equivalent to that in the iterative flowchart that is shown above.
This recursive function (and its iterative analogue) determines all the possible ways that a bill
for x dollars can be split among 3 people. One option might be that every person pays the
Page 3
same amount. Another option might be that one person pays for everything. The input in this
problem will represent the total amount of money to pay (in dollars) and the output will be
every possible way you could split the bill, assuming everyone pays a whole number of dollars.
For example, if the input $4, your function might list off these options:
A: $4,B: $0,C: $0
A: $3,B: $1,C: $0
A: $3,B: $0,C:$1
and soon.
However, if the user enters a negative number of dollars or a value that is not prefixed with a ' $ '
symbol, the output should read "Invalid Input".
A . [ Worth 1 3 points ] Function program 1 ( ) .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!