Design and implement an application that simulates a cash re

Design and implement an application that simulates a cash register. Base your design on the following informal scenario:

A cashier uses a scanner to enter the Universal Product Code (UPC) for products bought.

The cash register will then display the UPC, product name and unit price. After the last product is scanned, the cashier presses the \"Pay\" button. The cash register displays the total. The buyer hands over cash and the cash register displays the receipt on the screen (item name, UPC, and price for each, followed by the total price). To simulate this application, the user will enter the UPCs on the terminal (use a Scanner object). Output from the cash register is displayed on the terminal, using the System.out object.

Design classes that match the real-world objects (e.g. UPCScanner).

Follow the OO design process: identify classes, write CRC cards, UML class diagrams, sequence diagrams, state diagrams. Implement in Java and test your code. Hardcode several default products in a product inventory (e.g. prod: \"Snickers bar\", UPC: 101, Unit price: $1). Assume an infinite supply of products. Do not design/implement any features/functions that are not specified in this problem (no credit for extra features).

Comment your code, so the grader knows what is going on. Also add Javadoc comments.

Deliverables:

* CRC diagrams (bulleted list is acceptable)

* UML class diagrams, sequence diagrams, and state diagram for the class handling the cashier-system interaction

* Java code Paste in the Word doc or pdf file the CRC info, UML diagrams (exported to png from violet) and all your code.

Solution

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Grades {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
NumberFormat formatter = NumberFormat.getCurrencyInstance();
List<String> output = new ArrayList<String>();
double total = 0;
String done = \"y\";
while(done.equalsIgnoreCase(\"y\")){
System.out.println(\"Items Name: \");
String name = scanner.nextLine();
System.out.println(\"Price: \");
String price = scanner.nextLine();
System.out.println(\"Quantity: \");
String quantity = scanner.nextLine();
System.out.println(\"Do want to add more Items ?[Y/N] \");
done = scanner.nextLine();
Double amount = Double.parseDouble(quantity)* Double.parseDouble(price) ;
total = total+amount;
  
String result = name +\"\\t\"+quantity +\"\\t\"+formatter.format( Double.parseDouble(price))+\"\\t\"+formatter.format(amount);
output.add(result);
  
}
System.out.println(\"Name\\tQuantiyt\\tunitPrice\\tTotal\");
for(String line : output){
System.out.println(line);
}
String subtotal = \"Subtotal\"+\"\\t\\t\\t\"+formatter.format(total);
System.out.println(subtotal);
  
}

}

Design and implement an application that simulates a cash register. Base your design on the following informal scenario: A cashier uses a scanner to enter the U
Design and implement an application that simulates a cash register. Base your design on the following informal scenario: A cashier uses a scanner to enter the U

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site