 |
CS
139 Algorithm Development
PA1: Making Change
Due: Tuesday, Sep 24th at 11:59 PM
- -10% on Wednesday, Sep 25th
- -20% on Thursday, Sep 26th
- -35% on Friday, Sep 27th
- -50% on Sunday, Sep 29th
- Not accepted afterwards
|
 |
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.
- 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
Vending machines have a mechanism for accepting money, letting a user choose an item and then returning the correct amount of change in coins. You are writing a program that will carry out the process of calculating the change from the money entered. Since this is a simulation, you will need to prompt the user for the amount of money entered and the price of their choice and the program will then output the change amount in the count of coins required. You should assume that the user has entered the correct amount of money for the item purchased; in other words, assume that the money entered (tendered) is greater than or equal to the cost of the item purchased.
Requirements
PART A
You will provide 3 examples of different examples that will be used for your testing. These examples should include the tendered amount, the item cost and the coins returned. Part A will be in the form of a quiz and will have some additional questions. You must finish PART A before you can get help with PART B as you should always think through a problem before you attempt to solve it.
PART B
You will write a single Java program, ChangeMaker.java, that must:
- Prompt for and receive the money tendered using the prompt "Enter tender amount: " and the cursor
must remain on the line beside the space following the colon.
- Prompt for and receive the cost of the vending item. The
prompt must be of the form, "Enter purchase price: "
and the cursor must remain on the line beside the space
following the colon.
- Calculate the difference between the tender amount and the purchase price.
- Calculate the number of each kind of coin that must be returned to the user.
- Output a report in the following format:
<blank>
Change Maker
<blank>
Tender: $x.xx
Cost: $x.xx
Change: $x.xx
<blank>
Dollars: x
Quarters: x
Dimes: x
Nickels: x
Pennies: x
Each line above must end with the new line character directly following the output value and the blank lines <blank> in the output are significant. These lines should not include a blank space character, but should include a single new line character.
NOTES:
- Each of the 12 lines of output must be terminated with a
single newline "\n" character.
- All of the colons should line up vertically. The "Q" in Quarters must be in the first position of the line.
- Each line identified by <blank> should have a single newline character and no spaces.
- All currency amounts must be formatted with a $ followed by one or more digits followed by a decimal point and exactly 2 digits following the decimal place. Valid formatting would look like $0.50, $12.95, $1.50, etc.
- Coin counts should be integers and formatted as such.
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.
Deliverables
- Zip your PA1.java into a zip file. Submit the zip file via Web-CAT
(http://webcat.cs.jmu.edu).
- Your program will be judged on correctness (80%) and conformance to the StyleGuide (20%). The checkoff chart is found here.
Part C - Reflection
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 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 lab handouts, the TAs for any
CS139 or CS 149 section, and the Professor for your section. 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.
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.