INFO1103 Assignment 2
Due: Week 5 Lab, 2015
This assignment is worth 3% of your ?nal assessment
Task description
In this assignment you will improve your vending machine program so that it can perform transactions
using coins, calculate and dispense the correct amount of change and coin denominations required.
You are encouraged to ask questions on ed using the assignments category. As with any assignment,
make sure that your work is your own, and you do not share your code or solutions with other students.
Fetching the assignment ?les
To obtain the ?les for this assignment, run the following command on the labmachines or ucpu{1,2}
$ /labcommon/info1103/bin/get-assignment2
Academic declaration
By submitting this assignment you declare the following:
I declare that I have read and understood the University of Sydney Student Plagiarism: Coursework Policy and Procedure, and except where speci?cally
acknowledged, the work contained in this assignment/project is my own work, and has not been copied from other sources or been previously submitted
for award or assessment.
I understand that understand that failure to comply with the Student Plagiarism: Coursework Policy and Procedure can lead to severe penalties as
outlined under Chapter 8 of the University of Sydney By-Law 1999 (as amended). These penalties may be imposed in cases where any signi?cant
portion of my submitted work has been copied without proper acknowledgement from other sources, including published works, the internet, existing
programs, the work of other students, or work previously submitted for other awards or assessments.
I realise that I may be asked to identify those portions of the work contributed by me and required to demonstrate my knowledge of the relevant material
by answering oral questions or by undertaking supplementary work, either written or in the laboratory, in order to arrive at the ?nal assessment mark.
I acknowledge that the School of Information Technologies, in assessing this assignment, may reproduce it entirely, may provide a copy to another
member of faculty, and/or communicate a copy of this assignment to a plagiarism checking service or in-house computer program, and that a copy of
the assignment may be maintained by the service or the School of IT for the purpose of future plagiarism checking.
Implementation details
Write a program in Java that enables your vending machine to process transactions using coins. The
user will input their coins as payment, and the program will calculate and display the amount of
change to refund using the correct denominations, i.e. $2.00, $1.00, $0.50, $0.20, $0.10 and $0.05.
Your program will perform the following steps:
Display the price per can
Display the number of cans available
Display a message asking how many cans to purchase
Read the number of cans to purchase from input
Update any calculations as needed
Display the total amount of cans to be purchased
Display the total purchase price
REPEAT UNTIL enough coins have been entered for payment
Read the coin denomination from input
Update any calculations as needed
Calculate the amount of change and coin denominations
Display the amount of cans purchased
Display the number of cans remaining
Display the total purchase price
Display the amount paid by the user
Display the change given using the correct coin denominations
Important – your program must be contained in one ?le called and
produce no errors when compiled using javac on the lab machines. Your program will be run using
java VendingMachine and read input from standard input and write output to standard output.
Introduction to Programming Page 2 of 4INFO1103
Program input
? Ask the user to input 3 separate numbers of cans, with one number on each line.
These values will then be added up to calculate the total amount of cans to be purchased.
? Repeatedly ask the user to enter coins as payment until there is enough complete the purchase.
Program output
? Display the price per can and the total number of cans available.
? Display a purchase summary that includes the total purchase price, the amount paid by the user,
the amount of cans purchased, and the amount of change in the required coin denominations.
Program settings
? The price per can is $1.50
? The number of cans held in the machine is initially 300
Any change given must be dispensed using the smallest number of coins possible.
For example: $4.20 in change would dispensed with 2  $2.00 coins and 1  $0.20 coin.
Here are some examples of the payment process:
4 cans to purchase.
There are 296 cans left.
Purchase price is $6.00.
Please enter payment:
Purchase price is $6.00.
You gave $6.00.
Perfect! No change given.
Thank you, come again.
2 cans to purchase.
There are 298 cans left.
Purchase price is $3.00.
Please enter payment:
Purchase price is $3.00.
You gave $4.20.
Your change:
1 x $1.00
1 x $0.20
Thank you, come again.
Introduction to Programming Page 3 of 4INFO1103
Submission details
You must submit three A4 sheets of paper to your tutor during your week 5 tutorial.
? The ?rst sheet will contain the code that you have written for the purchase part of your vending
program, e.g. inputting coins, performing the transaction, and outputting the amount of change.
? The second sheet will contain a ?owchart diagram of your program states and transitions. This
diagram does not have a ?xed format and can be drawn by hand or using drawing software,
however it must be neat, tidy, legible and not require a magnify glass to read.
? The third sheet will be blank before your tutorial, and you will complete a desk check of your
program using the input decided by your tutor, e.g. purchase amounts and coin denominations.
You must also submit your code using the lab machines or undergraduate servers, described below.
The Make?le
We have provided you with a Make?le that can be used to build and submit your code.
The included Make?le will only run correctly on the lab machines and undergraduate servers.
? $ make
will compile your ?le into a class ?le VendingMachine.class
? $ make submission
will check your submission is valid, and submit a compressed archive of your assignment.
You are encouraged to submit multiple times, but only your last submission will be marked.
3 marks are assigned based on the diagram of your algorithm that you must to hand in at the start of
your tutorial, and also the desk check of input data that you will perform during your tutorial.
2 marks are assigned based on a manual inspection of the correctness, style and quality of your code.
1 mark is assigned based on whether you submit your code to the submission system.
Warning: Any attempts to deceive the marking system will result in an immediate zero for the
entire assignment. Negative marks can be assigned if you do not properly follow the assignment
speci?cation, or your code is unnecessarily or deliberately obfuscated.
Introduction to Programming Page 4 of 4