Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

3.

WRITTEN RESPONSES

3 a.
3.a.i.
The overall purpose is to be able to calculate how much you can tip your waiter with or without friends.

3.a.ii.
The functionality is the amount of tip for 3 different tip percentages being displayed depending on the bill and the number
of diners.

3.a.iii.
The input is the bill and the number of people splitting the bill while the output is the tip each person should pay.

3 b.
3.b.i.

3.b.ii.

3.b.iii.
The name is “tipPercent”

3.b.iv.
The data contained represents all the different percentages one can tip a waiter by.

3.b.v.
The list manages complexity because a for loop can simply be used to loop through all the tip percents so users can
pick the one which is acceptable. This also helps for scalability in case more percentages should be added. Otherwise,
different variables for each percent would be needed and the bill would have to be multiplied by each variable individually
to be displayed.

3 c.
3.c.i.
3.c.ii.

3.c.iii.
iii. The procedure both calculates and displays all the possible tips. It contributes to the overall functionality by fulfilling
the purpose of the program.

3.c.iv.
The algorithm first converts both bill and split to integers. If the split variable is 0, then loop through the list of
percentages, and for each different percent, put the resulting tip percent of the bill into the different textboxes.

3 d.
3.d.i.
First call:
calculateTip(50, 0);

Second call:
calculateTip(50,1);

3 d.ii.
Condition(s) tested by first call:
The condition tested in the first call is that split is equal to zero

Condition(s) tested by second call:


The condition in the second call is that split is greater than 0 (there are other people dining with the user).

3.d.iii.
Results of the first call:
Result is 5, 7.5, and 10 being displayed in 3 different text boxes representing the 10, 15, and 20 percent tips.

Results of the second call:


For the second input the result is 2.5, 3.75, and 5 in the 3 text boxes representing the tip each person should pay for the
same percentages.

You might also like