Develop a Java Application that uses an interactive Graphical
Weighting: 20%
Assignment Task In this assignment, you are required to write a Java Application that uses an interactive Graphical
User Interface (GUI) based on the JFrame class using SWING GUI components.
Your task is to develop a Java Application that allows the user to buy items from a vending machine.
The machine has three drop down lists to select available items, calculate the cost of selected items,
display the total cost, pay the cost and release the item. The application should contain a GUI as
shown below. The GUI components should consist of 1 Label, 3 Combo boxes/drop down lists (Select
Candy, Select Gum, Select Chips), 1 Text Area and 4 Buttons (Show Total Cost, Pay Cost, Release
Item, Exit). The layout managers are not used in this assignment. The components should be in the
same order as shown below.
The Candies, Gums and Chips and their costs are shown below in Tables 1-3.
Table 1. Candies and Cost
Candies Cost ($)
Freddo Frog 2.50
Flake 3.00
Jelly Snakes 3.50
Snickers 3.75
Table 2. Gums and Cost
Table 3. Chips and Cost
The functions of the four buttons are described below.
1. Show Total Cost The Show Total Cost button displays the total cost for the selected items as shown below. If no
item is selected then this button should display zero.
2. Pay Cost The Pay Cost button accepts money and displays an appropriate receipt with a change as shown
below.
Gums Cost ($)
Bubble Gum 2.00
Extra 3.00
Mentos 3.50
Minties 5.50
Chips Cost ($)
Smiths 3.00
Doritos 3.50
Thins 4.50
Pringles 6.00
3. Release Item The Release Item button checks if money has been paid and dispenses the purchased item by
displaying a message as shown below.
4. Exit The Exit button should allow the user to exit from the application.
Your application must have two classes (VendingItem and VendingApplication) as described
below.
VendingItem.java file
public class VendingItem
{
//Declare variables, constants and data structures as needed
//Constructor
//Methods
}
VendingItemApplication.java file
//Import packages
public class VendingItemApplication
{
//Declare variables, constants and data structures as needed
//Constructor
//Method to create label, comboboxes, buttons and register action listeners
//Method to create panels and add components
//Inner listener classes for comboboxes and buttons with actionPerformed method
public static void main(String[] args)
{
}
}
Assignment Submission You should submit the following three files using the Moodle online submission system.
VendingItem.java – Source code for VendingItem class
VendingItemApplication.java – Source code for VendingItemApplication class
Report.docx (this file contains a brief report that includes student name, student ID number,
course name, course code and test results (a few screen shots to show that your application is
working correctly))
Important Note You should start your assignment as early as possible. Your tutor will be checking your progress
in weeks 4 and 5.
You should not show your source code and report to any other student. You should not ask anyone to do your assignment. Please read CQU’s plagiarism guidelines.
Assignment 1 Marking Criteria
Total Marks – 20
Marks
Allocated
1 Graphical User Interface presentation – 1 mark for each component such as level,
combobox, text area and button (0 mark if program doesn’t run)
4
2 Design and use of appropriate data structures
2
3 Design and use of classes and listener classes (1 mark for listener classes and 1
mark for other classes)
2
4 Methods (1 main method, at least 2 methods in VendingItem class and 2 methods
in VendingApplication class) – 0.5 mark for each method
2.5
5 Quality of code (comments, indentation, naming and readability) – 0.5 mark for
each part
2
6 Show Total Cost button (0 mark if program doesn’t run) 1.5
7 Pay Cost button (0 mark if program doesn’t run) 2
8 Release Item and Exit buttons (0 mark if program doesn’t run)
2
9 Report (presentation and testing)
2
10 Penalty for submission of incorrect file names or format: 2 marks
11 Penalty for late submission: 5% / day or part of a day