You are to work with a partner, 2 students per group is the maximum. Group must submit for both students, only one copy of the assignment. Submission details are at the end of this document. The assignment has two parts.
Problem Description
Coffee N Roll is a small-town Sandwich Shop in rural Australia. The population is small so the Sandwich Shop sells only a small but select gourmet products. It sells five products only. Each product has a name and price.
The programming team require to demonstrate basic Java programming techniques, specifically using classes and objects. The aim of this assignment is to develop a top-down design and to write a program to be used as a cash register by the Coffee N Roll Sandwich Shop.
The assignment is composed of two parts. In Part 1, you are to write a Command Line Interface (CLI) cash register application and in Part 2 you create a Graphical User Interface (GUI) for the same cash register.
Part 1 Application Requirements
For our Java program simulation, a purchase transaction is sale and payment of a single product. For each sale, the program should prompt and get a numbered item corresponding to the product name and quantity of product purchased. The total cost of the purchase should be calculated and displayed. Then the program should ask the amount of money paid bythe customer. The calculated change will be displayed in dollars and cents as well as the currency denominations in banknotes and coins needed to make up the change in the most efficient way
For example, if the amount of change is $17.35 than the customer would be given 1 ´ ten-dollar banknote, 1 ´
five-dollar note, 1 ´ two-dollar coin, 1 ´ twenty-cent piece, 1 ´ ten-cent piece, and 1 ´ five-cent piece.
At the end of the day the cashier enters Done to end the simulation. The program should then display the total amount of sales in each of the five categories and terminate. The five product menu is shown if Figure 1.
Coffee N Roll Menu
Item | Name | Price |
1. | Schnitzel Roll | $18.80 |
2. | Fish Roll | $17.25 |
3. | Lamb Roll | $9.60 |
4. | Ice Cream Roll | $6.75 |
5. | Coffee Latte | $3.40 |
6. | Done |
Figure 1. Coffee N Roll product menu.
Analysis
The program will be launched from the class CoffeeNRoll containing the main( ) method. Product is a good choice for a class with information about products for sale in the Coffee N Roll. The price can be set or updated by calling setPrice( ) method of Product class. Also, we will construct a class Change to return the correct change and currency denominations for a particular sale, by calculating the smallest number of required $100, $50, $20, $10, $5 banknotes and $2, $1, 50c, 20c, 10c, 5c coins.
A sample of an UML class diagrams
The public class Product
The class Change
The class CoffeeNRoll
Program simulate the Coffee N Roll cash register. It will handle all user inputs. The class CoffeeNRoll outline is as follows:
import java.util.Scanner; public class CoffeeNRoll
{
public static void main(String[ ] args)
{
// in main( ) create and initialise all five Product(s), one Change, and other objects
//other information which must be stored. See sample run below
//format price as currency and pad leading spaces to right justify price
//display menu, see samples below
//loop until user selects item 6. Done from the Coffee N Roll menu.
} //end of main method
} //end of class CoffeeNRoll
Data Input
Output
Note: All money data will be stored in cents but displayed as dollars.cents. This avoids rounding problems. All data input should request the cent value. (This is actually what happens with a real cash register when the cashier enters 2000 for $20 then hits “00 key” provided on the keyboard for dollar entry. If you tender
$20.50 the cashier enters 2050.
A sample output
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
──────────────────────────────────
1. Schnitzel Roll | $18.80 |
2. Fish Roll | $17.25 |
3. Lamb Roll | $14.60 |
4. Ice Cream Roll | $6.75 |
5. Coffee Latte | $3.40 |
6. Done |
──────────────────────────────────
Enter the item number you want to order: 1 Enter quantity ordered: 3
Sale price: $56.40
Enter the amount paid in cents [0-1000000]: 10035 The change is: $43.95
The change returned to the customer is:
──────────────────────────────────
| Number of20 dollar notes:2 |
| Number of2 dollar coins:1 |
| Number of1 dollar coins:1 |
| Number of50 centscoins:1 |
| Number of20 centscoins:2 |
| Number of5 centscoins:1 |
──────────────────────────────────
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
──────────────────────────────────
1. Schnitzel Roll | $18.80 |
2. Fish Roll | $17.25 |
3. Lamb Roll | $14.60 |
4. Ice Cream Roll | $6.75 |
5. Coffee Latte | $3.40 |
6. Done |
──────────────────────────────────
Enter the item number you want to order: 5 Enter quantity ordered: 8
Sale price: $27.20
Enter the amount paid in cents [0-1000000]: 5000 The change is: $22.80
The change returned to the customer is:
──────────────────────────────────
| Number of20 dollar notes:1 |
| Number of2 dollar coins:1 |
| Number of50 centscoins:1 |
| Number of20 centscoins:1 |
| Number of10 centscoins:1 |
──────────────────────────────────
Sale 1
Sale 2
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
──────────────────────────────────
1. Schnitzel Roll | $18.80 |
2. Fish Roll | $17.25 |
3. Lamb Roll | $14.60 |
4. Ice Cream Roll | $6.75 |
5. Coffee Latte | $3.40 |
6. Done
──────────────────────────────────
Enter the item number you want to order: 1 Enter quantity ordered: 2
Sale price: $37.60
Enter the amount paid in cents [0-1000000]: 5055 The change is: $12.95
The change returned to the customer is:
──────────────────────────────────
| Number of10 dollar notes:1 |
| Number of2 dollar coins:1 |
| Number of50 centscoins:1 |
| Number of20 centscoins:2 |
| Number of5 centscoins:1 |
──────────────────────────────────
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
──────────────────────────────────
1. Schnitzel Roll | $18.80 |
2. Fish Roll | $17.25 |
3. Lamb Roll | $14.60 |
4. Ice Cream Roll | $6.75 |
5. Coffee Latte | $3.40 |
6. Done |
──────────────────────────────────
Enter the item number you want to order: 3 Enter quantity ordered: 3
Sale price: $43.80
Enter the amount paid in cents [0-1000000]: 11075 The change is: $66.95
The change returned to the customer is:
──────────────────────────────────
| Number of50 dollar notes:1 |
| Number of10 dollar notes:1 |
| Number of5 dollar notes:1 |
| Number of1 dollar coins:1 |
| Number of50 centscoins:1 |
| Number of20 centscoins:2 |
| Number of5 centscoins:1 |
──────────────────────────────────
Sale 3
Sale 4
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
──────────────────────────────────
1. Schnitzel Roll | $18.80 |
2. Fish Roll | $17.25 |
3. Lamb Roll | $14.60 |
4. Ice Cream Roll | $6.75 |
5. Coffee Latte | $3.40 |
6. Done
──────────────────────────────────
Enter the item number you want to order: 4 Enter quantity ordered: 7
Sale price: $47.25
Enter the amount paid in cents [0-1000000]: 10000 The change is: $52.75
The change returned to the customer is:
──────────────────────────────────
| Number of50 dollar notes:1 |
| Number of2 dollar coins:1 |
| Number of50 centscoins:1 |
| Number of20 centscoins:1 |
| Number of5 centscoins:1 |
──────────────────────────────────
Sale 5
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
──────────────────────────────────
1. Schnitzel Roll | $18.80 |
2. Fish Roll | $17.25 |
3. Lamb Roll | $14.60 |
4. Ice Cream Roll | $6.75 |
5. Coffee Latte | $3.40 |
6. Done |
──────────────────────────────────
Enter the item number you want to order: 6
Total Schnitzel Roll Sales: $94.00 Total Fish Roll Sales: $0.00 Total Lamb Roll Sales: $43.80 Total Ice Cream Roll Sales: $47.25 Total Coffee Latte Sales: $27.20
──────────
TotalDaily Sales:$212.25
End of day trading
End of the day Sales summary
Part 2: GUI Application
Design a GUI application to manage the Coffee N Roll sandwich shop. The GUI needs to be able to accomplish the same input and output tasks as the command line driven program was able to do.
The appearance of the GUI is entirely up to you to decide. Feel free to add any extra features that you feel are useful.
Note: Do not rewrite any of the classes from Part 1 of the assignment. Rather you will create instances of the relevant classes when you need them for Part 2. The GUI for this assignment should create at least two new classes one being the JFrame and the other CashRegGUI JPanel with its components.
import javax.swing.*;
//Create JFrame container public class CNR_GUI {
public static void main(String[] args) {//main method JFrame frame = new JFrame("CashReg");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new CashRegGUI()); frame.pack();
create GUI panel
frame.setVisible(true);
} //end of main
} //end CNR_GUI
Choose GUI components that reduce user errors and provide a feedback to the user. For example,
Figure 2. Basic Cash Register GUI application layout
Consider the following controls as a minimum requirements as shown in Figure 2:
Figure 3. Screen image of the fully working Java GUI application
Submission Details and Marking Scheme
It is compulsory that you demonstrate your work to your lab instructor in week 12. Submission of the assignment with code and other deliverables (refer to ‘What you have to hand in’ section below) are due on Sunday 16th of February 2020 at 11:59 PM. Emailed submissions will not be accepted.
The late assignments will be penalised 4 marks per day until the submission cut-off date. However, if you have a good reason for not finishing on time, you may apply to VU for a time extension special consideration.
What do you have to hand in?
An electronic copy of
For solution, connect with our online professionals NOW!