CS139 Algorithm
Development
|
|
Software Requirements Specification
Programming Assignment 2
Dukes ISP (Internet Service Provider) Billing
Due Tuesday, October 16 by 11:59pm (midnight) - Hardcopy in
class Wednesday.
Introduction
Purpose: This programming
assignment is based on the assignment in your book, pg 174-13 and 14.
Objectives - At
the conclusion of this exercise the student will demonstrate that they
can:
- Solve a problem involving decision structures.
- Use methods to structure the code.
- Validate input and end program execution after 2 tries for
valid data.
- Use the
NumberFormat
or DecimalFormat
class to properly format currency values.
- Do everything necessary to create, debug, and run
a java program.
- Use comments to delineate each section of the program.
- Adhere to a Style Guide.
- READ AND FOLLOW DIRECTIONS!!!!!
Deadlines
- Submit: October 16, 2007 by 11:59pm. Use your
instructor's preferred submission mechanism.
- Report: October 17, 2007 by the beginning of class. A 20
points/day late penalty will apply for each of the 2 deadlines. If the
submit is late, the report is due the next class or lab session day
after successful submission. Programs will not be accepted
after 3 days late. All hardcopy submitted must be stapled.
Problem description:
An Internet service provider has three different subscription packages
for its customers.
Package Charges:
Package |
Price per month |
Ceiling hours |
Additional hours |
Package A |
$9.95 |
10 |
$2.00 |
Package B |
$13.95 |
20 |
$1.00 |
Package C |
19.95 |
unlimited |
Not applicable |
Your program should prompt for and read the package and the hours and
calculate the cost to the user. In addition, these packages
are taxed by the locality at the rate of 5%. Your program
should calculate the tax on the total cost to the user and print a bill
stating the package, the number of hours, the cost broken down by
monthly price, hours, additional hours, and additional hours.
The format is specified below.
In addition, if the user has either package A or B, your bill should
display a message if the user would have saved money under either of
the other two plans. This savings should be displayed as the non-taxed
amount. If there would be no savings or if the user is on
Package C, don't display a message.
Prerequisites
You understand the material in Chapter 3 and Chapter 5.1 of
Gaddis.
Program Behavior
Your application must do these things:
- Prompt for the letter of the customer's package, A, B, or C
and read in the value.
- You must allow for either upper case or lower case
letters. A and a are equivalent.
- If a package other than A, B, or C is specified, display
an error message and re prompt the user and reread a value.
- If a package other than A, B, or C is specified a second
time, display an error message and exit the program.
- Prompt for the number of hours of usage. This
number may be whole hours or parts of hours expressed as a decimal
number.
- If something other than a positive (or 0) number is
entered, display an error message and re prompt the user and reread a
value.
- If something other than a positive (or 0) number is
entered a second time, display an error message and exit the program.
- Based on the chart above (Package charges), display the
total amount of the charges based on the description below in output
and the chart above.
- Calculate the tax using the 5% rate. Display the
tax amount.
- Calculate the total bill and display this amount.
- Compare the total charge with the charge for the other
higher packages (A --> B and C, B --> C) and display
savings, if any, of moving to the higher package.
Output
- Output the heading, "Dukes ISP Billing" followed by the
newline character.
- Output a blank line.
- Prompt for the input values. Output the newline character
after reading the each input value and before the next prompt. Note:
your input will be on the same line as the prompt.
- Your first input prompt must be the String, "Enter the
package code (A, B, or C): "
- Your second input prompt must be the String, "Enter the
number of hours used: "
- Error messages. If either of the first two reads
are invalid, display the message, "Your entry, " + badentryValue + "
is invalid. Please try again." , where badentryValue is
the erroneous value read in on its own line. You should then
display the original prompt on a new line and re prompt with the
original prompt.
- After reading all of the input values, output a blank line
then the bill as follows. The bold values are calculated
values as described above.
- All money amounts should be displayed with $ symbol and
decimal point. The hours should be displayed to 2 decimal
points.
Customer Bill
Package: packageCode
Hours Used: hours
Base Charge: base
Base Hours: baseHours (omit this line for Package C)
Additional Hours: hours (omit this line for Package C)
Total Charge: charge
Tax: taxCharge
Pay this Amount: totalBill
If
the user is using package A or B and they could save money on package B
or C, output a blank line and then the following message as
appropriate. Display two messages if two packages will provide
savings. If there is no savings or the savings would be on a
lower base cost package, do not display the message.
You could have saved savings with package packageCode. Call 1-888-555-1234 for more information.
Additional Program Requirements
- You must have at least two classes. One class will hold the main
method and the
other will represent the charges. All input and
output will be done in
the main method with methods in the ISPCharge.java
class doing all of
the
calculations. You must use this file for your "starter" and must
fill out all of the listed methods. Method headers must not be
changed.
- You may add another class if you want and you may add methods to the ISPCharge.java file if you want.
- ISPCharge will represent the charge for one customer. It
will store the package and hours, then use these values to calculate
the various parts of the bill.
- You must use named constants as appropriate.
- You must display any error messages directly after the
wrong input. For example, if the user enters an incorrect package code,
you must immediately display the error message and reprompt for input.
- Your program must include an acknowledgement section
acknowledging help received from TAs or reference sources. You do not
need to reference receiving help from the instructor.
- If you received no help your acknowledgement section should
have a statement to that effect. See they Style Guide for exact wording.
- Your program must conform to standard Java programming
standards and the additional standards for this class. See the Style
Guide for your class.
Suggestions for building your solution
- Understand the problem. Make sure that you know which "player" will perform each of the actions in this assignment.
- Create "stubs" in ISPCharge.java and build a driver to test each method in isolation.
- Design each of the methods before you code any of them.
What do you need to do, for example, to calculate the charge for
package A? What must you do to compare the charges?
- Implement each method.
- Test each of these methods using your driver before you try to incorporate them in the final working program.
- Design your final program. What must happen first, second
third? Don't worry about error checking or the comparison part
until you have it working with "expected" data and can produce a basic
bill.
- Test each part thoroughly as you are building it.
- Pay attention to the interface. This is not going through a
submit test process, so you will need to make sure that your output
conforms to these specifications. Ask questions if there is any ambiguity.
- Document as you are going along. The methods in ISPCharge
should be updated to reflect the actual code you implement.
Document your steps in the main method.
Honor Code
This work must conform to the JMU Honor Code and the specific
requirements
of this class. NO help may be provided by another student to another
student.
Authorized help is limited to your textbook, the TA’s for any
CS139
section, and the professor for your section. See collaboration policy.
Grading
- Your program will be evaluated both by its correctness in calculating the charges and
conformance to the required elements.
- You will achieve a grade of 80 for a program that runs
correctly
and produces exactly the required output in the required format.
- The remainder (20) will be based on your conformance to the
Style and other requirements of the assignment. Review the Style Guide
before submitting your program and the grade sheet which is produced by
the submit system.
- All grades will be based on 100 points.
- You may submit any number of times. The only one I will
count is the one that corresponds to the hardcopy report that you turn
in.
- The hardcopy that you turn in will be the formatted version
that
I will check. Make sure it has no line wraps or other spacing
issues.
- Successfully submitted programs that are late will be
graded, then the 20 point penalty assessed for each day late.
HINTS
- Begin early. Students run into trouble by waiting
too long to start the program.
- Understand the problem at hand. Make sure that
you follow
the requirements precisely. Don't add additional
"flourishes".
You will be downgraded.