
I never saw a Purple Cow,
I never hope to see one;
But I can tell you, anyhow,
I'd rather see than be one.
Gelette Burgess, 1895
But a Purple Cow is just what you would expect to see as the mascot of the JMmoo Dairy Bar |
CS 139
Algorithm Development
PA3: JMmoo Dairy Bar
Part
A Due in Canvas by Friday,October 17 at 11:59PM
Part B Due in WebCAT by
Wednesday, October 22 at 11:59 PM
- -10% on Thursday October 23
- -20% on Friday, October 24
- -35% on Sunday, October 26
- -50% on Monday, October 27
- Not accepted afterwards
Part C due in Canvas by
Thursday,October 23 or one day after you have successfully submitted to
WebCAT.
Part D due in class on
Friday, October 24 or one day after you have successfully submitted
to
WebCAT.
|
 |
Updates:
- 10/19/2014 - Changed the structure to say that the list of methods should be in JMmoo.java not JmmooDriver.java.
- 10/19/2014 - Changed the description of the calcPrice method to say it takes in 4 parameters as listed below.
- 10/19/2014 - Clarified that the calcPrice method returns a double value.
- 10/19/2014 - Clarified that it is okay to add methods to JMmoo.java and as a matter of fact, you should think carefully about what additional methods might be helpful (like checking for y/n values).
Objectives - At the conclusion of this assignment students will
have demonstrated that they can:
- Input data from a keyboard.
- Validate that data using the Scanner has methods and if statements.
- Use Java math operations.
- Organize operations into individual methods.
- 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
The JMU West Campus is jealous of the homemade ice cream at E-Hall. So in PC Dukes, there will be a new JMmoo Dairy Bar offering made to order homemade ice cream confections. Your job is to write the software application that will help the servers price the ice cream.
Requirements
PART A - Graded as a homework assignment. There
will be a separate Canvas Assignment for this.
You will need to provide test cases that will show that you understand the different branches(alternatives) that will be used for pricing.
Pricing is calculated as follows:
There will always be a "special". That special is a flat $5.00. (For example, it might be a double scoop in a chocolate dipped sugar cone with sprinkles.)
A single scoop in a regular cone or dish is $1.00. A double scoop is $2.00. A triple scoop is $2.75.
A sugar cone adds $.50 to the cost of the confection. A waffle cone adds a dollar.
Sprinkles, nuts, chocolate coating each cost $.50 for a single scoop, $.75 for a double or triple.
PART B - Submitted to webcat.
You will write a Java program consisting of JMmooDriver.java and
JMmoo.java, that must:
- Display a welcome message, "Welcome to the JMmoo Dairy Bar"
- Display a blank line
- Prompt for and receive the customer's choices for their ice cream using the following prompts:
- "Do you want the special? " - The answer should be entered as y or n. Any value entered that is not y or n in either form should be treated as an n.
- If they answer y to the special question, skip to the end and display the price as shown below.
- "How many scoops? " - The answer should be entered as 1, 2, or 3. Any other value including bad values such as 'a' should be treated as 1.
- "What kind of cone (r-regular, s-sugar, w-waffle)? " - The answer should be entered as r, s, or w. Treat any value other than an r, s, or w as r.
- "Do you want sprinkles? " - The answer should be y or n only. Treat any other value as n.
- "Do you want nuts? " _ The answer should be y or n only. Treat any other value as n.
- "Do you want chocolate coating? " - The answer should be y or n only. Treat any other value as n.
- Calculate the cost for the ice cream and display the result in the following form.
<blank>
Your ice cream costs $xxx.xx.
This line must end with the new line character. The format of the amount is the same as for PA2.
Output MUST conform exactly to that shown. Failure to match it
exactly will result in WebCAT errors. 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.
A complete dialog (with input values highlighted in red would look
like)
Welcome to the JMmoo Dairy Bar
<blank>
Do you want the special? n
How many scoops? 1
What kind of cone (r-regular, s-sugar, w-waffle)? r
Do you want sprinkles? n
Do you want nuts? n
Do you want chocolate coating? n
Note, this blank line is in the dialog because it would be the return from entering n.
<blank>
Your ice cream costs $ 1.00.
NOTES:
- There will be only four new line characters in the output...one for the welcome, one for the blank line after the welcome, one for the blank line beneath the user entry, and one to close out the last line of output.
- 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.
Part B Structure
JMmooDriver will contain a single method, main which will call all of
the other methods in JMmoo to perform the calculations and
output the results. Nothing should be directly output in JMmooDriver.
JMmoo will have the following methods:
-
inputInteger has two parameters, a Scanner
object (built in main), and a String prompt to prompt the user for the value. The method should use the
prompt to print a message to the user and then read in an integer value. If the value the user enters is not an integer or is not one of the allowable numbers (1,2 or 3) then return 1. To avoid conflict with the inputYN method, this method must consume the new line character.
- inputYN has two
parameters, a Scanner object (built in main) and a String prompt. The
method should use the prompt to print a message to the user and then
read in a String value. The String is then returned by the method.
- formatBillAmount has one
parameter, the amount to format as a double. It returns a String which
is the amount formatted as shown in the examples, with a $ followed by
0, 1, or 2 spaces depending on the dollar amount, a decimal point and
two digits rounded. NOTE: String has a method, format, which will
behave like printf, except that it will not print the value, but
instead will return a String.
- calcPrice will calculate
the price and return it as a double value. It has 4 parameters as follows (NOTE: the order is important):
- special - special is boolean, true if they are getting the flat rate special, false otherwise.
- scoops - an integer which has the number of ice cream scoops.
- cone - a char value which will contain r, s, or w depending on the kind of cone they are getting.
- extras - a count of the number of extra toppings the user is getting.
- printWelcome will print the welcome message and the following blank line. It takes in no parameters and does not return anything.
- printPrice will print the final two lines (the blank line and the cost message. It will take in a single parameter which is the cost of the ice cream as a double.
You will likely want to add additional methods to JMmoo.java.
Part B Deliverables
- Zip your JMmooDriver.java and JMmoo.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.
Deductions for failing to follow the structure will be taken from the
80% correctness score.
Part C, D - Reflection and Pair Programming Log - graded as
regular homework assignments. 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.
In addition, you should keep a log showing how much time you and
your partner worked together and how much time you worked alone.
Honor Code
This is a pair programming assignment. You may work with your
partner, but may not work with any other team. 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 or CS 149 section, and either professor. Copying work
from another student not in your partnership 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.