Lab 2 - I/O and Basic Computation
Due - September 27/28, 2004
In this lab, you will write a program that performs basic
computation and user input/output. Your job is to write a program
that will calculate the cost of a user's monthly cellular phone
bill. The cellular provider's pricing scheme is below:
$0.05 per minute 7AM - 12noon and 1PM - 7PM
$0.08 per minute 12noon - 1PM
$0.03 per minute 7PM - 7AM
$0.04 per minute 7AM - 7PM
free 7PM - 7AM
You must ask the user for the number of minutes she has used
during each time period. Store her responses and then use them to
calculate the total charges for the month. Finally, print the
total charges for the user.
Begin by writing the algorithm for this program. As an
example, suppose the pricing scheme were $0.05 7AM - 7PM $0.03
7PM - 7AM. Your algorithm might look as follows:
//ask user for number of day minutes and store in variable DAY
//ask user for number of night minutes and store in variable NIGHT
//calculate total charges as (DAY*.05) + (NIGHT*.03) and store
in variable TOTAL
//display value in TOTAL for user
Your algorithm and program will be slightly more complex since the
pricing scheme you will follow is more complex.
Implementation Hints You should use printf to
print each prompt for the user and scanf to read in each
response and store the response in a variable. Make sure you do
this one item at a time. Once you have completed the calculation,
use printf to print the result for the user.
Part 1 - Due - Monday, September 20, 2004 - 8:35AM Submit
a program design and series of test cases. Your design should
consist of the algorithm you plan to implement for this program.
Your test cases should describe a series of tests you plan to
perform to ensure that your program functions correctly. An
example test case might look as follows:
Test case 1
Weekday 7am-12noon: 67
Weekday 12oon-1pm: 13
Weekday 1pm-7pm: 56
Weekday 7pm-7am: 150
Weekend 7am-7pm: 250
Weekend 7pm-7am: 74
Expected result: 21.69
Part 2 - Due - September 27/28, 2004 - Beginning of Lab
Submit your completed code.
- Make sure you have completely documented your program including your name, date, filename, and a description of the program. See the worksheet you received in your first lab for an example of this documentation.
- Make sure a lab assistant (Dianne or I) has seen your program run.
- Copy and paste the output of your program to the bottom of your program itself. Make sure the output is a comment. That means, put a /* before the output and a */ after the output.