Abc Assignment Help

NIT2112 Writing JAVA Program for Cash Register by Coffee N Roll Sandwich Shop Assessment Answer

“Coffee N Roll Sandwich Shop” Programming

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. Producis 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

  • 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)

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

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.

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: 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: 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: 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: 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: 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,

 Basic Cash Register GUI application layout

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
    Full marks will be given for a completely functional basic layout but additional marks may be given by better working GUI.

Screen image of the fully working Java GUI application

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

  1. Readme.docx file with information on how to run

Answer

For solution, connect with our online professionals NOW!

Customer Testimonials