/**
 * CS149 - Introduction to Programming
 * Department of Computer Science
 * James Madison University
 * @version Fall 2018
 */

PA2: Brendon's Bakery Warehouse (Methods)

Due Dates and Submission Details

See submission details below for all due dates and submission details. Note there are multiple submission parts.

Honor Code

This assignment should be completed individually to maximize learning. It is important that you adhere to the Course Policies, particularly the section on Programming Assignments. Also relevant is the JMU Honor Code.

Objectives

Instructions

Your Bakery.java program has been a tremendous success, and the bakery is selling more goods than ever before! To keep up with demand, the owner has opened up a warehouse to handle all orders with quantities 100 or over and needs you to implement more features for the program to be used at the warehouse:

Getting Started

Since the program is starting to get long, you will need to improve your PA1 submission by organizing it into multiple well-documented methods. Make a copy of your PA1 source file and name it Bakery2.java. Don't forget to rename the class to Bakery2 for it to compile, and while you're at it update the @version tag. Then add the following methods to your program (above main). An important part of this assignment will be to write method javadoc comments with @param and @return tags where applicable.

The constants for the tax rate and discount rate will be shared across the whole class. To declare these where the whole class can make use of them, copy the following lines directly beneath the class header (i.e., the first element inside the class):

public static final double TAX_RATE = 5.3;

public static final int DISCOUNT = 20;

The public keyword means the variable is visible outside this class. The static keyword means the variable will be shared by all instances of the class. The final keyword means that the variable is only assigned once and is a constant. (We'll learn more about these concepts later in the semester.)

Methods

Each of the methods below should be declared above main and implemented exactly as described. Only one Scanner should be declared and used in the entire class. It should be declared in main and then passed as an argument to each method as appropriate.

You will still have a main method as before, but it will primarily call the other methods to do most (but not all) of the work. In particular, main should declare a single Scanner that will be passed to each method. As before, many variables (but not all) will be declared in main. Make sure you do not duplicate any effort between your main method and the supporting methods.

As in the previous assignment, there is no need to handle invalid user input (e.g., the user typing in a string when you're expecting a double).

Examples and Testing

The files below contain example input and corresponding expected output of a finished program. You must use these files to perform diff/meld testing similar to the Command Line Testing Lab lab. It is highly unlikely that you will be able to get the format exactly right without using this testing technique. This is the purpose of the detailed description and formatting requirements - to get you to use command-line testing.

Submission

This assignment has two parts that should be completed in order. By the first deadline you must complete a readiness quiz in Canvas, by the second deadline you must submit your completed code through AutoLab.

Part A - Friday September 14, 11:00PM

Read this entire document and complete the quiz in Canvas. The grading for this quiz is all-or-nothing. You must answer all questions correctly by the deadline to get any credit. You will have as many attempts as you need, but if you do not answer all questions correctly by the deadline or you will receive no credit for this part.

Part B - Friday September 21st, 11:00PM

Upload your completed Bakery2.java file through AutoLab.

You must implement the above in java, creating a file called Bakery2.java. Before uploading your Bakery.java file, be sure to complete the following steps carefully:

Your submission will be graded using the following criteria:

RequirementPoints
PART A: Readiness Quiz10
PART B: Checkstyle10
PART B: Javadoc and Comments10
PART B: Accurate algebraic calculations20
PART B: Accurate modulus calculations10
PART B: I/O and Formatting10
PART B: Proper method calls10
PART B: Passes Diff Testing10
PART B: Instructor grading based on style and code quality10

Don't put off submission until the last possible minute! Any submission system may become bogged down when it receives a large number of submissions. You may have some unanticipated difficulties uploading your code. It is your responsibility to take these possibilities into account and submit early enough to ensure that the submission process is completed before the deadline.

Hints

Format the floating point values in the final report of totals as right justified numbers in an unspecified number of spaces with 2 places after the decimal point. Also, compute the discount by subtracting the discounted price from the full price. Compute the discounted price by multiplying each average price returned by printProduct by the quantity entered by the user.

For a nice summary of printf format specifiers, look here.

Going Further

Why did we use the colors above (input/output)?

Acknowledgments

This assignment was originally developed by Nathan Sprague and repurposed by Dee Weikle.