NIT2112 Assignment NIT2112 Object Oriented Programming Page 1 “Coffee N Roll Sandwich Shop” Programming Assignment Due date: Sunday 21th of April 2021 at 11:59 PM *** No late submission *** Marks: The...

1 answer below »
nj


NIT2112 Assignment NIT2112 Object Oriented Programming Page 1 “Coffee N Roll Sandwich Shop” Programming Assignment Due date: Sunday 21th of April 2021 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 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, twenty- dollar, 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 | |
Answered Same DayApr 12, 2021NIT2112

Answer To: NIT2112 Assignment NIT2112 Object Oriented Programming Page 1 “Coffee N Roll Sandwich Shop”...

Swapnil answered on Apr 12 2021
149 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here