CS 0401 Assignment 1
Assignment 1
Topics: Review of expressions, conditions, loops and I/O
ASSIGNMENT DATE: 13 JAN 2016 (MW class), 14 JAN 2016 (TH class)
DUE DATE: 1 FEB 2016 (MW class), 2 FEB 2016 (TH class)
LATE DUE DATE: 3 FEB 2016 (MW class), 4 FEB (TH class)
You have opened a bookstore, and have decided to write your own point-of-sale system to sell books. You sell several items:
Customers can purchase any number of each item. However, if a customer purchases bookmarks, it will always give them packs if possible, thus allowing for a cheaper price. For example, if somebody buys 3 bookmarks, they will not buy a pack - it will cost them $3.00. However, if they buy 7, then they will automatically get one pack and one extra bookmark, for a total cost of $5.00 + $1.00 = $6.00 - not $7.00.
We will assume that you are operating the bookstore in Oakland, so you will need to add 7% additional tax (Pennsylvania and Allegheny County taxes) on all sales. For example, if somebody buys one book at $5.00, then the total cost should be $5.00 + $0.35 in tax, or $5.35.
All values should be rounded to the nearest cent.
Additionally, in order to attract business, you are running a promotion: every third customer will get 10% off their order (before tax). This will start with the third customer; the first customer will not get a discount, the second customer will not get a discount, but the third one, sixth one, ninth one, etc. will. For example, if the third customer buys a book, they would get $0.50 off (10% of $5.00), for a total of $4.50, and then tax would be added ($4.185, which would be rounded to $4.82).
If the customer does not get a discount, then along with the receipt, the message "You did not get a discount! Better luck next time!" If the customer does get a discount, display the discount amount and the message "You won a 10% discount!"
You will write a Java program that runs a point-of-sale service for your bookstore. The program should do the following:
Sample output will be put in the file sample_output.txt (in this directory) and grading will be based on the rubric listed at official_rubric.md (also in this directory).
Tips:
for
loop, you will need to use a different index variable name.int schmeckle
which stores the number of books bought, it does not give informationVariables.java
file in the sample_code
directory. Be sure to explain what is happening at a higher abstraction, don't just say what the code is doing - for example, do not comment x = x + 2
with the comment // Add 2 to x variable
. This does not tell the reader anything about what the code is doing or why. Definitely include your name, course number, and what the project should do at the beginning of the Java file.Scanner
class for inputting data. There are other methods, but only use this one for this assignment.$
in front, and rounded to nearest cent (1 / 100th of a dollar). For example, $1.17
, not 1.17
, $1.17000000000
, and definitely not 1
.THIS:
public int doSomething(int a) {
if (a > 0) {
a = a + 3;
}
return a;
}
NOT
public
int doSomething(int
a) {
if (a > 0) { a =
a + 3; } return
a;
}
The latter will compile, but this is harder to read and not good coding style.
Create a private repo and share it with me and the graders, by the time the program is due (see above).
If you do not yet have the ability to make a private repo (because your student pack has not yet come in, for example), please hold off on pushing to GitHub. You may want to work on the project, then copy it into a repo later.
Please include all source files (i.e., .java files) necessary for your program to compile and run. There should be no .class files, Eclipse-related files, etc. Remember you can use git rm filename to remove files from git, if you accidentally add some.
You will need to turn in a submission sheet with your assignment (see submission_sheet.md). Please fill out all the required sections. This should be printed out and turned in in class - do not add it to the GitHub repo.
Extra credit is up to the discretion of the grader, but will not be more than five points. Be sure to mention what the extra credit is on the submission sheet! Some ideas for extra credit, in order from "least impressive" to "most impressive" (and thus more points) are: