/** * CS139 - Programming Fundamentals * Department of Computer Science * James Madison University * @version Spring 2016 */
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!
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:
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.
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:
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.)
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.
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.
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:
Requirement | Points |
---|---|
PART A Readiness Quiz | 10 |
Javadoc and comments | 15 |
Variable names / types | 15 |
Prompts and data input | 20 |
Accurate calculations | 10 |
Output and formatting | 20 |
Code Formatting | 10 |
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.
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.
This assignment was originally developed by Chris Mayfield.