
|
CS
139 Algorithm Development
PA3: ISP Charges
Part
A Due in Canvas by Friday, Mar 20 at 11:59PM
Part B Due in WebCAT by
Tuesday, Mar 24
at 11:59 PM
Late assignments will be
accepted in accordance with the following penalties:
- -10% on Wednesday Mar
25
- -20% on Thursday Mar 26
- -30% on Friday Mar 27
- -40% on Sunday Mar 29
- -50% on Monday Mar 30
- Not accepted afterwards
Part
C due in Canvas by Wednesday Mar 26 or one day after you have
successfully submitted to WebCAT whichever is later.
|
UPDATES:
- If a pagage does not need additional hours (C) then you should not print the additional hours line. See the clarification in red below. (03/17/2015)
- Correction to the spacing the the package C example.(3/22/2015)
- To insure consistency, display hours with a single digit to the right of the decimal place (3/22/2015)
- Changed (see red) to make all examples consistent with the webcat solution. (3/23/2015)
Objectives - At the conclusion
of this assignment students will have demonstrated that they can:
- Input data from a keyboard.
- Use Java math operations.
- Properly format output to
specification.
- Divide a problem up into
different modules and methods.
- Use appropriate decision
structures to choose among several options.
- Validate data and use
default values when data does not conform to specification.
- Do everything necessary to
create, debug, and run a java
program.
- Use comments to delineate
each section of the program.
- Adhere to a Java Style Guide.
- READ
AND FOLLOW DIRECTIONS!!!!!
Background
This PA is based on Programming Challenge 13 and 14 in your text. "An
internet service provide has three different subscription packages for
its customers.
Package A: For $9.95 / month:
10 hours of access are provided. Additional hours are: $2.00 / hr.
Package B: For $13.95 / month:
20 hours of access are provided. Additional hours are: $1.00 / hr.
Package C: For $19.95 / month:
unlimited access is provided. "
Your job is to read in the
hours and the package code and produce a statement for the charges. In
addition, if a higher base fee package will save the customer money,
you should print a statement to that effect showing the savings. If
there are no savings, or if a lower base fee package would save money,
no message is displayed.
Requirements
PART
A - Graded as a homework
assignment. There
will be a separate Canvas Assignment for this and you will submit to
PA3-PtA in WebCAT.
You are provided with a
documented shell class, ISPCharge.java.
You must provide a JUnit test
file which will test each of the methods in the class. See futher
information in the class notes for class on Monday Mar 16 regarding the
constructor method and the global variables. NOTE: You do not need code
to build a test file, but I am providing a class file that you can use
for your testing. It is written correctly. (ISPCharge.class)
PART
B - Submitted to webcat. WebCAT
will be made available no later than Sunday morning Mar 22. NOTE: Each
of your methods will be tested separately. Your methods must conform to
the design requirements below. You will also need to submit your own
test file to WebCAT.
You will write a Java
applicataion consisting of two files. ISPBilling.java will
include all IO and will control the production of the statement. Your
main method may be no longer than 25 lines excluding declarations. If
it is longer, create separate methods to handle repetitive or more
complex tasks. Insure that you are building only one Scanner object.
Pass it as necessary to your methods. Your application must:
- Prompt for the hours and
subscription package values.
- Insure that the entry is
correct (within acceptable values). If not, an error is displayed to
the user and a default value provided to the application. Note the
Error Handling section below.
- Calculate the appropriate
charge for the customer for this month based on the overall description
of the subscription rates and additional charges.
- Calculate the tax based on a
rate of 5%.
- Determine if another higher
base package will save the customer money.
- Display the statement and
the savings messages (if appropriate).
A complete dialog as it would
appear at the command line would look like this. (with input values
highlighted in red and italicized). Notice how the labels all line up.
The A of Additional Hours is left justified in the first position of
the line.
Dukes ISP Billing
Enter the package code (A, B, or C): A
Enter the number of hours used: 20
Customer Bill
Package: A
Hours used: 20.0
Base charge: $9.95
Additional hours: 10.0
Total charge: $29.95
Tax: $1.50
Pay this amount: $31.45
You could have saved $16.00 with package B. Call 1-888-555-1234 for more information.
You could have saved $10.00 with package C. Call 1-888-555-1234 for more information.
Output specifications
Prompts
- Each input prompt must use a
print statement. There should be no new line character at the end of
the prompt. Notice how the input is placed directly beside the
corresponding prompt.
- You must use the exact
verbiage as shown in the sample dialog.
- The prompts must be in the
order shown.
- Each prompt ends with a :
and a single space.
- If a package does not charge for hours (package C) then the Additional hours line should not print. (Note: this does not change the spacing of the rest of the lines. An example:
Dukes ISP Billing
Enter the package code (A, B, or C): C
Enter the number of hours used: 20
Customer Bill
Package: C
Hours used: 20.0
Base charge: $19.95
Total charge: $19.95
Tax: $1.00
Pay this amount: $20.95
Results
- Each line of result output
should terminate with the new line character.
- Each line should use the
exact verbiage as found in the sample dialog.
- The first line of result
output should be a blank line.
- The next two lines echo the
input (or default value - see error handling) used to produce the bill.
- A blank line follows.
- The base charge and
additional hours print. Use currency format for the amount. You do not
need to format the hours.
- A blank line follows.
- Next the total charge and
tax lines print.
- A blank line follows.
- The total charge (charge +
tax) prints.
- If there are savings:
- A blank line prints.
- Then one or two lines of
savings print.
Additional
notes in output:
- All input prompts must use a
print (or printf) but must not include a new line character. A colon
and space end the prompt.
- Money amounts must use
currency format. Make sure that the result is rounded to two decimal
positions. Do not use the %6.2F specification since we are not printing
in 6 characters.
- The hour amounts do not need
to be formatted.
- All output labels (not input
prompts) must print with the colons lined up. The Additional hours
prompt is the longest. (Think reuse...where have you done this
before?)
Error
handling:
- The only valid characters
for the subscription are 'A', 'a', 'B', 'b', 'C', and 'c'. If anything
else is entered, display "You entered " followed by the bad value
followed by a period and space. One the same line, display "Using A"
and use the 'A' package as the default for calculation and output the
new line character. NOTE: if they enter "Apple" that is not the same as
entering 'A'.
- If anything other than a
decimal number greater than or equal to 0 is entered for the hours,
display "You entered " followed by the bad value followed by a period
and space. On the same line, display "Using 0." and then output the new
line character.
- A sample dialog with error
messages is displayed.
Dukes ISP Billing
Enter the package code (A, B, or C): q
You entered q. Using A
Enter the number of hours used: -87.uu
You entered -87.uu. Using 0
Customer Bill
Package: A
Hours used: 10.0
Base charge: $9.95
Additional hours: 0.0
Total charge: $9.95
Tax: $0.50
Pay this amount: $10.45
NOTES:
- You should use constants for
any numberic value with meaning.
- For this and every other PA,
you should only create 1 Scanner object. Multiple Scanner
instantiations (new Scanner...) will cause WebCAT to fail.
- Your program should use
appropriate data types for the values being input and calculated, and
appropriate and meaningful names for all variables and constants.
- The program source must
follow all StyleGuide conventions used in this class.
Design Requirements
- You must use the starter
file ISPCharge.java.
- You must call your driver
ISPBilling.java.
- You may add additional
methods to either ISPBilling.java or ISPCharge.java, but ONLY if they
are adding simplicity to the code or removing complex calculations.
Style
Requirements
- As always, use the class
Style Guide as a guide. It is found in Canvas in the Resources module.
I will enforce putting methods in alphabetic order on this PA.
- If no acknowledgement is
provided, you will be deducted 5 points instead of the usual 2. This
must be in at least the file containing main.
- Any absent class or method
documentation will be deducted 2 points for each occurence.
- The shell program documentation is incomplete and contains
embedded instructions. You must clean up this documentation to include
all required elements and to remove any comments such as ("The rest is
left for you to fill in...").
Part B Deliverables
- You should submit,
ISPBilling.java and ISPCharge.jave to via
Web-CAT (http://webcat.cs.jmu.edu).
You must package your files into a single zip package because you can
only upload a single file to WebCAT.
- Your program will be judged
on correctness (80%) and conformance to the StyleGuide
(20%). Your program must pass all submission tests to be graded. The
checkoff chart is found in Canvas in the Resources module..
Part C Reflection - graded as
a regular homework assignment. There will be separate Canvas
Assignments
for this.
You will write a reflection
document for this assignment which will
let you consider the process of building this program. It will also
contain a place to critique this assignment for this class.
Honor Code
This is an individual
programming assignment. This assignment should be viewed as a take home
exam. Your work on the assignment and your submission must conform to
the JMU Honor
Code. Authorized help is limited
to the classroom handouts, lab material, the TAs for any CS139, our
graduate student and the professor. Copying work from another student
or the Internet is an honor code violation, which will result in a zero
on the assignment and
possibly further sanctions. You may use the internet to search for
help, but each site that you use hould be acknowledged in the Reference
section of the code documentation.
Your work on this assignment is
subject to review by MOSS
which is a plagiarism detection tool for programs. Submission to WebCAT
constitutes your submission of work for academic credit and your
agreement that your work may be submitted to MOSS.