go to previous page   go to home page   go to next page hear noise highlighting

Answer:

Enter the price:
100
Item cost: 100 Tax: 5.0 Total: 105.0

Three-way Decisions

An if statement makes a two-way decision. Surely you must sometimes pick from more than just two branches?

We ran into this problem with a previous example program that divided integers into negative and non-negative. It really should pick one of three choices:

Two-way decisions can do this. First divide the integers into two groups (using a two-way decision):

Then further divide the second group (by using another two-way decision):

By repeatedly splitting groups into subgroups, you can split a collection into any number of fine divisions.


QUESTION 16:

How could you divide a group of people into:


go to previous page   go to home page   go to next page