A Problem Solved: Health Club Welcome

In this lesson, we will solve the health club problem mentioned in the prelude to this chapter.

We'll cover the following

Problem statement

In this chapter’s overview, we suggested a program that you could write for a health club that asks for a person’s age and gives some simple advice about available facilities that are age-appropriate. To complete this program, we need to know the health club’s policies and what it offers its members. A conversation with the club’s fitness director provides us with the following information: Children under 10 should be directed to the children’s center for either daycare or organized and supervised activities.

Older children under 13 can use the swimming pool and soccer fields. Teenagers under 17 are welcome to use the entire complex but should be cautioned about overtraining. People who are 17 to 49 years of age can use the entire complex. They should get a specific note about the swimming pool and the basketball league. Finally, those members who are 50 and older must have consulted a doctor before beginning an exercise program. The club has a physician on staff for this purpose.

Solution

The program given below is a possible solution to this problem that uses a multiway if statement.

Run this program and test it with various ages.

Get hands-on with 1400+ tech skills courses.