Russell Gordon

The Cell Sell

10 October, 2020

    After reading this puzzle's description, it should be evident that your job is to finish a program that will compare cell phone plan costs in scenarios that vary based upon how many minutes someone spent talking during the day, the evening, and on weekends.

    NOTE: Yes, kids, at one time, this is how cell phone plans were priced. In some cases, they still are priced this way.

    It's worth firing up the debugger in Xcode to slow things down and understand what the code is doing for you here. Please follow along as you watch this video.

    Set a breakpoint on line 29, after input will have been provided by the user.

    Let's run the program. Say someone uses 300 minutes during the day in a week, and 100 minutes in the evening.

    What the code is doing for you is calculating costs according to the table in the puzzle description. You can see the results of calculations, and the impact on the contents of each variable, in the bottom left of the Xcode interface, as you step through the code.

    In this case, we can see that Plan A is a bit more expensive.

    If you compare the code that's already written to the problem description, you can see weekend minutes aren't yet accounted for.

    As well, be sure to note the threshold for free daytime minutes in each plan.

    Try entering 50 minutes for the number of daytime minutes someone uses.

    What happens to the cost for Plan A? For Plan B? What does that imply that you need to do?

    HINT: Use a control structure that runs a block of code only under some conditions. What kind of control structure would that be?

    Note that 50 minutes falls below the "free daytime minutes" threshold for both cell phone plans.

    Experiment with this, and with some thought, you'll figure it out. Have fun!