CSC 221: Computer Programming I
Fall 2001

HW3: Programs with Conditionals


Few tasks in life are more complex than selecting long distance service. Numerous long distance service providers exists, both nationally and locally, and each of those in turn offers numerous calling plans to choose from. This can be viewed as positive for the consumer, who is able to choose plans tailored to personal calling patterns, or negative due to the overall complexity of the system. In fact, Scott Adams described the long distance service industry as a "confusopoly", where a group of companies with similar products resort to confusing the customer as opposed to competing directly on price (The Dilbert Future, Scott Adams, Harper-Collins Publishers, Inc., 1997).

The following long distance plans were taken from the Sprint Web site www.sprint.com on 9/29/01, and don't even exhaust the selection of plans offered. Note: the selection of Sprint over other long distance service providers such as AT&T and MCI is purely random. It is not intended as an endorsement or criticism of Sprint or its policies.

Sprint Nickel Anytime
5 cents/min (anytime)
$8.95 monthly fee
Sprint Sense Anytime
10 cents/min (anytime)
$4.95 monthly fee
Sprint 500 Anytime
500 anytime min included, 10 cents/min after that   
$25 monthly fee
Sprint 1000 Anytime
1000 anytime min included, 10 cents/min after that   
$40 monthly fee
Sprint Nickel Nights
5 cents/min nights (7pm to 7am)
10 cents/min daytime (7am to 7pm)
$5.95 monthly fee
Sprint 1000 Nights
1000 nightime min included, 10 cents/min after that
10 cents/min daytime (7am to 7pm)
$20 monthly fee

You are to write a C++ program that allows the customer to determine which of these plans best meets their needs, based on their calling patterns. First, the program should ask whether the user is interested in a specific plan or in comparing the costs under all plans. In the case of a specific plan, the program should prompt the user to determine which of the six plans is of interest, and also the number of daytime and night minutes that they foresee using each month. In the case of the second option, comparing all plans, the costs under all of the six plans should be computed and displayed (entering the daytime and night minutes only once, of course).

The following sample executions demonstrate the intended behavior of the program (with user input displayed in bold):

Welcome to Dave's Sprint plan guide.
Are you interested in:
  (1) a specific plan, or
  (2) a comparison of all plans?
Select an option: 2

How many daytime (7am to 7pm) minutes do you foresee using in a month? 100
How many night (7pm to 7am) minutes do you foresee using in a month?   100

Your bill would be:
  $18.95 using Sprint Nickel Anytime
  $24.95 using Sprint Sense Anytime
  $25.00 using Sprint 500 Anytime
  $40.00 using Sprint 1000 Anytime
  $20.95 using Sprint Nickel Nights
  $30.00 using Sprint 1000 Nights

Welcome to Dave's Sprint plan guide.
Are you interested in:
  (1) a specific plan, or
  (2) a comparison of all plans?
Select an option: 1

Which plan are you interested in?
  (1) Sprint Nickel Anytime
  (2) Sprint Sense Anytime
  (3) Sprint 500 Anytime
  (4) Sprint 1000 Anytime
  (5) Sprint Nickel Nights
  (6) Sprint 1000 Nights
Select an option: 3

How many daytime (7am to 7pm) minutes do you foresee using in a month? 100
How many night (7pm to 7am) minutes do you foresee using in a month?   100

Your bill would be:
  $25.00 using Sprint 500 Anytime

Requirement 1: At the bare minimum, your program should define functions for each of the different calling plans, with parameters corresponding to the values that vary for that plan, either total minutes (for the Anytime plans) or daytime and night minutes (for the Night plans). Other function definitions may be called for as well.

Requirement 2: Your program should produce meaningful output even if the customer enters invalid responses at the prompts. For example, if the customer enters a 3 at the first prompt (where only two options are presented), the program should display an error message and exit gracefully. Likewise if the customer enters an invalid plan number at the second prompt. In the case of an invalid response, the user should NOT be prompted for daytime and night minutes.

Requirement 3: As you start to write more complex programs, readability becomes an even higher priority. This and all subsequent programs should meet the following style guidelines: