Professional Writers
We assemble our team by selectively choosing highly skilled writers, each boasting specialized knowledge in specific subject areas and a robust background in academic writing
Fill the order form details - writing instructions guides, and get your paper done.
Posted: March 16th, 2022
Object Oriented Programming
NIT2112 Object Oriented Programming
Page 1
“Coffee N Roll Sandwich Shop” Programming Assignment
Due date: Wednesday 16th of March 2022 at 11:59 PM
*** No late submission ***
Marks: The assignment is worth 40% of the total unit mark.
You are to work individual. You must submit 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
AssignmentTutorOnline
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.
NIT2112 Object Oriented Programming
Page 2
A sample of an UML class diagrams
(a) The public class Product
• Product(String name) //constructor initialises data attributes
• setPrice(int cents) //sets Product price in cents.
• addToTotal(int amount) //adds current sale to total, recorded in cents
• getName( ) //returns the product name
• getPrice( ) //returns product’s price in cents
• getTotal( ) //returns day’s sales in cents
• reset( ) //reset attributes (required by GUI app only)
(b) The class Change
• Change( ) // constructor initialises data attributes
• denChange(int amount) //calculate and store currency denominations
• getNotes( ) //returns array of banknote denominations
• getCoins( ) //returns array of coin denominations
(c) The class CoffeeNRoll
• main(String[ ] args) //launch application
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
• Product name (Schnitzel Roll, Fish Roll, Lamb Roll, Ice Cream Roll, Coffee Latter or Done). Use
menu’s item number to select the desired product. A separate class can validate and handle all inputs.
• Quantity
• Amount of money received from customer in cents
Output
• Total amount of purchase = quantity * product_price
• Change returned to customer = amount tendered – amount purchased)
• In addition to the amount of change, display the number of hundred-dollar, fifty-dollar, twentydollar, ten-dollar and five-dollar notes, two-dollar coins, one-dollar coins, fifty-cent, twenty-cent,
ten-cent and five-cent coins.
• Use printf( ) to align on right (right justify) the menu’s price column.
• At the end of the day (menu item 6. Done entered) display the total dollars of sales for each of the
five product categories and totals for the day.
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.
Change
– notes[ ] : int
– coins[ ] : int
– other attributes
+ Change( )
+ denChange(int) : void
+ getNotes( ) : int[]
+ getCoins( ) : int[]
+ other methods
Product
– name : String
– price : int
– total : int
– other attributes
+ Product(int)
+ setPrice(int) : void
+ addToTotal(int) : void
+ getName( ) : String
+ getPrice( ) : String
+ getTotal( ) : int
+ other methods
NIT2112 Object Oriented Programming
Page 3
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 of 20 dollar notes: 2 |
| Number of 2 dollar coins: 1 |
| Number of 1 dollar coins: 1 |
| Number of 50 cents coins: 1 |
| Number of 20 cents coins: 2 |
| Number of 5 cents coins: 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 of 20 dollar notes: 1 |
| Number of 2 dollar coins: 1 |
| Number of 50 cents coins: 1 |
| Number of 20 cents coins: 1 |
| Number of 10 cents coins: 1 |
──────────────────────────────────
Sale 1
Sale 2
NIT2112 Object Oriented Programming
Page 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: 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 of 10 dollar notes: 1 |
| Number of 2 dollar coins: 1 |
| Number of 50 cents coins: 1 |
| Number of 20 cents coins: 2 |
| Number of 5 cents coins: 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 of 50 dollar notes: 1 |
| Number of 10 dollar notes: 1 |
| Number of 5 dollar notes: 1 |
| Number of 1 dollar coins: 1 |
| Number of 50 cents coins: 1 |
| Number of 20 cents coins: 2 |
| Number of 5 cents coins: 1 |
──────────────────────────────────
Sale 3
Sale 4
NIT2112 Object Oriented Programming
Page 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: 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 of 50 dollar notes: 1 |
| Number of 2 dollar coins: 1 |
| Number of 50 cents coins: 1 |
| Number of 20 cents coins: 1 |
| Number of 5 cents coins: 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: 6
Total Schnitzel Roll Sales: $94.00
Total
Total Fish Roll Sales:
Lamb Roll Sales: $0.00
$43.80
Total Ice Cream Roll Sales:
Total Coffee Latte Sales: $47.25
$27.20
──────────
$212.25
Total Daily Sales:
End of the day
Sales summary
End of day trading
Sale 5
NIT2112 Object Oriented Programming
Page 6
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.
Choose GUI components that reduce user errors and provide a feedback to the user. For example,
Number of 100 dollar notes: 2
Number of 50 dollar notes: 2
Number of 20 dollar notes: 2
Number of 10 dollar notes: 2
Number of 5 dollar notes: 2
Number of 2 dollar coins: 1
Number of 1 dollar coins: 1
3
Paid (cents) 10035
─────────────────────────────────
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
─────────────────────────────────
Quantity
Change $43.95
Total Daily Sales: $212.25
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
Reset Done
Sale price $56.40
Coffee N Roll Cash Register
Figure 2. Basic Cash Register GUI application layout
Consider the following controls as a minimum requirements as shown in Figure 2:
• Reset button to clear and enable all fields. total for each product set 0. Do not clear product prices!
• Done button lists day trading summary in Cell 6 text area.
• Text field to display warnings and user errors (pink background text field in Sub-Cell 1, in Figuew 2).
• Sale, Quantity, Paid and Change text field display sale price, product quantity, cash tendered and change.
• Two text area to display denomination of change (Cell 4) and day trading summary (Cell 6).
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()); //create GUI panel
frame.pack();
frame.setVisible(true);
} //end of main
} //end CNR_GUI
JFrame container divided
as GridLayout(3, 2)
Cell 5 panel subdivided
as GridLayout(5, 1)
Cell 1 panel subdivided
as GridLayout(2, 1)
Sub-cell 1
2 3 4 5
Cell 2 Cell 1
Cell 3, Product name and
price as button labels Cell 4
Cell 6
Cell 3. Use JButtons to
select product or
advanced GUI with radio
buttons
NIT2112 Object Oriented Programming
Page 7
Full marks will be given for a completely functional basic layout but additional marks may be given by better
working GUI.
Figure 3. Screen image of the fully working Java GUI application (free stock image of the antique cash
register from https://www.pexels.com)
Submission Details and Marking Scheme
It is compulsory that you demonstrate your work to your lab instructor in Session 11. Submission of the
assignment with code and other deliverables (refer to ‘What you have to hand in’ section below) are due on
Wednesday 16th of March 2022 at 11:59 PM. Emailed submissions will not be accepted.
*** Late submission will not be accepted except as outlined below***
The late assignments will be penalized 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
Readme.docx file with information on how to run your program. Get custom essay samples and course-specific study resources via course hero homework for you service – Include any extra information about
your design and program that you wish the marker to know.
NIT2112 Object Oriented Programming
Page 8
A word document with the evidence of trial runs of your program, i.e., jGRASP console output for CLI
app or screen printouts of GUI results where you have tested all the features of your code.UML
diagram for all classes in your program.
Code for all the classes that has been compiled and are ready to run. (jGRASP or NetBeans will be used to
run and test your application)
A brief description of the class. At the start of each method, there should be a comment clearly describing
what the method does. Each class should be fully documented commencing with a heading. In
particular, the heading should include your name, unit, assignment details, date written and a
brief description of the class. At the start of each method, there should be a comment clearly
describing what the method does.
Hint: Start Early! Don’t underestimate the amount of time needed to write and test the program, nor the
complexity of this assignment.
NIT2112 – Assignment
Name………………………….. Name…………………………..
ID No………………………. ID No……………………….
Markers Guideline
Allocated
Marks Mark
achieved
Appropriate design including UML class diagrams and description of
how to solve the problem plus readme.docs file.
Printout of extensive trial runs 10
class Product — design and implementation 10
class Change — design and implementation 10
Other classes for CLI application — useability and implementation. 10
class CashRegGUI Windows application — design and implementation.
Any other classes. 15
Output & Functionality — program works and meets specification.
Whole Program
• Originality, user friendliness and presentation.
• Appropriate commenting of code and readability of the code. 25
Demo
You Want Quality and That’s What We Deliver
We assemble our team by selectively choosing highly skilled writers, each boasting specialized knowledge in specific subject areas and a robust background in academic writing
Our service is committed to delivering the finest writers at the most competitive rates, ensuring that affordability is balanced with uncompromising quality. Our pricing strategy is designed to be both fair and reasonable, standing out favorably against other writing services in the market.
Rest assured, you'll never receive a product tainted by plagiarism or AI-generated content. Each paper is research-written by human writers, followed by a rigorous scanning process of the final draft before it's delivered to you, ensuring the content is entirely original and maintaining our unwavering commitment to providing plagiarism-free work.
When you decide to place an order with Nurscola, here is what happens: