/**
 * CS139 - Programming Fundamentals
 * Department of Computer Science
 * James Madison University
 * @version Spring 2016
 */

PA1: Invoice Maker (Basic I/O)

Objectives

Getting Started

You've just landed an exciting part-time job at a local bakery that supplies convenience stores all over the Shenandoah Valley. Their breads and pastries are the best around, but the owner has been filling out invoices 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 invoices. The rest is history.

See the example input and output below for the general idea. Create a new source file named Invoice.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 First Name: Becky
Enter Customer's Last Name: Thatcher
Enter Item Code: cake17
Enter Item Qty: 10
Enter Item Price: 5.99
Enter Discount Percent: 20

Specifically:

  1. Read a customer's first name and last name separately. Remember that some names have spaces in them.
  2. Read details of the item that the customer purchased. (People never buy more than one thing at a time.)
  3. Each item has an alphanumeric code, i.e., a single word with a reasonable number of letters and digits.
  4. Quantity (Qty) is the number of items purchased by the customer. This will always be a whole number.
  5. The price of an item can be a decimal value or a whole number, and it is measured in US dollars.
  6. The discount percentage 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.

Writing Output

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

MADISON BAKERY

Becky Thatcher
Date: 02/04/16

Item	Qty	Price
----	---	-----
cake17	10	5.99

Before tax: 59.900000000000006
Discount @20%: 11.98
Tax @5%: 2.3960000000000004
Total: 50.316

Specifically:

  1. Display the name of the bakery (MADISON BAKERY), followed by a blank line.
  2. Display the customer name (first name followed by last name, separated by a single space).
  3. Display the assignment deadline in mm/dd/yy format, followed by a blank line.
  4. Display the details of the item the user entered, with the columns separated by tabs, followed by a blank line.
  5. Calculate and display the total before tax.
  6. Display the discount percentage and the price after the discount is applied.
  7. Display the tax rate (5%) and the tax amount.
  8. Calculate and display the total cost to the customer.
  9. Print a blank line before and after the entire invoice.

Note that you may see strange results like 59.900000000000006 instead of 59.90. 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 two deadlines. By the first deadline you must complete a readiness quiz in Canvas, by the second deadline you must submit your completed code through Web-CAT.

Part A - Monday February 1st, 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 to get any credit. You cannot receive credit for Part B unless you successfully complete Part A.

Part B - Thursday February 4th, 11:00PM

Before the second deadline you must upload your completed Invoice.java file through Web-CAT.

Make sure to test your code carefully to ensure that it meets all of the requirements above. When you submit, Web-CAT will run some very superficial tests. For example, your code will fail the submission tests if it doesn't produce any terminal output. Your PA grade will not be based on these tests. Your code will be graded by hand. The submission tests are there to make sure that your code at least compiles and executes.

Your submission will be graded using the following criteria:

RequirementPoints
PART A Readiness Quiz10
Javadoc and comments15
Variable names / types15
Prompts and data input20
Accurate calculations10
Output and formatting20
Code Formatting10

For future PA's we will introduce some detailed requirements for code formatting. For now, just make sure that your code is neat and consistent:

Don't put off submission until the last possible minute! The Web-CAT 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.

Honor Code

This assignment must be completed individually. Your submission must conform to the JMU Honor Code. Authorized help is limited to general discussion on Piazza, the lab assistants assigned to CS 139, and the instructor. Copying work from another student or the Internet is an honor code violation and will be grounds for a reduced or failing grade in the course.

Acknowledgments

This assignment was originally developed by Chris Mayfield.