5. Nested Structures¶
Consider the telephone company “Chao”. Below 200 minutes, the company charges
$0.20
per minute. Between 200 and 400 minutes, the price is$0.18
. Above 400 minutes, the price per minute is$0.15
. Calculate your phone bill with these conditions.The company’s conditions can be visually represented by the path of a road like the following image.
Nested conditions can be created.
Remember to indent nested portions of code.
Note the double indentation to satisfy the second condition.
Now we modify the “Chao” company program for a promotion where the rate is
$0.08
when you use more than 800 minutes.
Note that nested structures can grow.
It is used to check multiple conditions.
You have attempted of activities on this page