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

PA1: Brendon's Bakery (Basic I/O)

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

Getting Started

You've just landed an exciting part-time job at a local bakery that is known throughout the Shenandoah Valley. Their breads and pastries are the best around, especially their unique cupcakes. Unfortunately, the owner has been filling out receipts for individual customers by hand since the shop opened in 1787. After working there for a few days, you mention that you're taking a programming course and might be able to help automate the process of writing receipts. The rest is history.

See the example input and output below for the general idea. Create a new source file named Bakery.java and implement the entire program in the main method. Provide a meaningful Javadoc comment, including @author and @version tags. Write concise inline comments (using //) for each major section of the assignment described below (e.g., gathering input, doing calculations, displaying output). You should have these comments in place before writing any code!

Reading Input

Your program will need to read and store a variety of information while displaying the prompts as shown in the following example:

Enter Customer's Personal Name: Jordan
Enter Customer's Family Name: Lee
Enter Product Code: cake22
Enter Product Quantity: 12
Enter Product Price: 0.99
Enter Discount Percent: 10

Specifically:

  1. Read a customer's personal (first) name and family (last) name separately. Remember that some names have spaces or other special characters in them.
  2. Read the alphanumeric code of the product that the customer purchased. (Customers are not allowed more than one type of product at a time. Alphanumeric codes will be no longer than 7 characters, 4-5 characters followed by 1-2 numbers.
  3. Read the quantity (number of items) purchased by the customer. This will always be a whole number under 100.
  4. Read the price of the item. The price can be a decimal value or a whole number, and it is measured in US dollars.
  5. Read the discount percentage. It will be an integer value. If the user enters 10, this means a 10% discount.

To get started, declare variables with meaningful names and types. Initialize a Scanner to handle the input, and use System.out.print to display each prompt exactly as shown. There is no need to handle invalid user input in this assignment.

Performing Calculations

  1. Perform any calculations that need to be made to turn the input into the values required in the output. Note that the discount is given BEFORE the tax is computed.

Writing Output

Use the collected data to display a receipt that matches the following example exactly as shown. Insert a tab character (but no other spaces) between each column of the item table.

*****                  *****
\___/ BRENDON'S BAKERY \___/

Jordan Lee
Date: 09/07/2018

Product	  Qty	Price
-------	  ---	-----
cake22	  12	$0.99

Initial Cost: $11.879999999999999
Discount at 10.0%: $1.188
Tax at 5.3%: $0.566676
Final Cost: $11.258675999999998

Specifically:

  1. Print a blank line.
  2. Display the name of the bakery (BRENDON'S BAKERY), along with the cupcake logo. This will require printing two lines. The first will be five asterisks (*), followed by 18 spaces, followed by five more asterisks (*). The second will be a backslash, three underscores, a forward slash, a space, the name of the bakery, a space, a backslash, three underscores, and a forward slash.
  3. Print a blank line.
  4. Display the customer name (personal name followed by family name, separated by a single space).
  5. Display the assignment deadline in mm/dd/yyyy format.
  6. Print a blank line.
  7. Display the details of the item the user entered, with the first two columns separated by one tab and the second and third columns separated by two tabs.
  8. Print a blank line.
  9. Calculate and display the total before discount or tax.
  10. Display the discount percentage and the price after the discount is applied.
  11. Display the tax rate (5.3%) and the tax amount.
  12. Calculate and display the total cost to the customer.
  13. Print a blank line.

Note that you may see strange results like 11.879999999999999 instead of 11.88. We will learn later in the semester how do deal with this problem. For now, you must simply print all values as-is. (Don't try to round, truncate, or format them to two decimal places.)

Submission

This assignment has three deadlines/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 complete a textual algorithm quiz in Canvas, and by the third deadline you must submit your completed code through AutoLab.

Part A - Friday August 31st, 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 - Monday August 3rd, 11:00PM

After reading the specification and doing the quiz, you should complete the algorithm quiz in Canvas. Note that you only have one submission opportunity for this quiz so be careful taking it. NO LATE SUBMISSIONS WILL RECEIVE CREDIT FOR THIS PART!

Part C - Friday September 7th, 11:00PM

Upload your completed Bakery.java file through AutoLab.

  • Verify that your code is working. You should test it with several of your own tests, but included here are a pa1test1.in and a pa1test1.exp to give you one verified command-line test. Note if your output is not exactly like the output in `pa1test.exp` when run on `pa1test.in`, then your code is not correct.
  • Make sure all your variables are declared at the beginning of the `main()` method, before any other statements.
  • Check that you have inserted the proper javadoc `@author` and `@version` comments in the appropriate header.
  • Run Checkstyle and eliminate ALL warnings about your code.
  • Your submission will be graded using the following criteria:

    RequirementPoints
    PART A: Readiness Quiz10
    PART B: Algorithm10
    PART C: Checkstyle10
    PART C: Correctly scanned input20
    PART C: Accurate calculations20
    PART C: Correctly formatted output20
    PART C: 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.

    Going Further

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

    Acknowledgments

    This assignment was originally developed by Chris Mayfield, edited by Nathan Sprague and repurposed by Dee Weikle.