Lab Assignment 2 (1)
Lab Assignment 2 (1)
2
This assignment covers GUIs and enumerations. It is out of 50 marks, 30 for question 1
and 20 marks for question 2. You must complete your answer using the IntelliJ template
provided. In both questions the style and quality of your code will be taken into
consideration when allocating marks.
Write a class that implements a program to calculate each diner's share of a meal in a
restaurant. The application should take the bill price, add a tip expressed as a
percentage, and then divide by the people present. For full marks you should correctly
handle erroneous input. You must use the Swing library as presented in class without
using an interface builder or other tool.
When nished your GUI will resemble the following. You should make use of a single ow
layout manager in your implementation, so resizing will change the layout.
fi
fl
Question 2: Change Calculator (20 marks)
Complete the change calculator. In this question you will write an Enumeration for the
various coins and notes available in pounds sterling.
PENCE1 1 “1p”
PENCE2 2 “2p”
PENCE5 5 “5p”
PENCE10 10 “10p”
PENCE20 20 “20p”
PENCE50 50 “50p”
For example, if the price is £28.99 and the paid amount is £40.00 the TreeMap returned
would contain:
Create a GUI for the ChangeCalculator. Use the ChangeCalcGUI class for your
implementation. The design of your GUI is up to you. Marks will be awarded for the
e ective use of Swing complements, the quality of your code and having a usable layout.
Again, you must use the Swing library as presented in class without using an interface
builder or other tool.
ff
ff