Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Point of Sale UI IN JAVA Point of sale interfaces are designed to simplify the p

ID: 3690705 • Letter: P

Question

Point of Sale UI IN JAVA

Point of sale interfaces are designed to simplify the process of making transactions, often in a retail environment. We often see them used in restaurants where managers can input the menu and waiters can quickly enter customer orders, which are transmitted to the kitchen and recorded. Modern systems usually include a touchscreen interface, which we will simulate with a mouse-based GUI.

The program you should design and build will read a menu from a text file formatted with a menu item and a price separated by a |. To simplify your text-parsing code, we will omit the dollar sign from the price.

For example:

The program should load the file at launch and create a panel full of large buttons (ideal for a touchscreen) for each menu item. A waiter should be able to click on each menu item to add it to the current order. This should add the item to a receipt panel which displays the full order and the total cost. The total cost should be accurate at all times, updated as each item is added (not only when the order is finalized).

The system only takes credit card as payment type however it can handle/validate multiple types of credit cards. (Please see credit card section below).

The waiter should be able to click a “Place Order” button that simulates transmitting the order to the kitchen by printing the order to System.out (in addition to showing the confirmation on screen). You should also include a “Clear” button that will clear the current order (used when a waiter makes a mistake and needs to start over).

Credit Card

In your system you have the following class structure for the credit cards:
     a class CreditCard,
     classes VisaCC, MasterCC, AmExCC that are all subclasses of CreditCard,
     you assume more subclasses for other credit card types will be added later on.
You now have to design the method(s) (and maybe additional classes) that verifies that the credit card number is a possible account number, and creates an instance of the appropriate credit card class.


Important details: Credit card numbers cannot exceed 19 digits, including a single check digit in the rightmost position. The exact algorithm for calculating the check digit as defined in ISO 2894/ANSI 4.13 is not important for this assignment. You can also determine the card issuer based on the credit card number:

Hint: you face here (at least) two problems, one has to do with how you figure out what kind of card a specific record is about, the other one with how you create the appropriate objects. Look at behavioural patterns and at creational patterns.

MasterCard First digit is a 5, second digit is in range 1 through 5 inclusive. Only valid lenght of number is 16 digits. Visa First digit is a 4. Length is either 13 or 16 digits. AmericanExpress First digit is a 3 and second digit a 4 or 7. Length is 15 digits. Discover First four digits are 6011. Length is 16 digits.

Explanation / Answer

public class CSCard { private static double interestRate; private static double newBalance; private static double interest; public static void main(String[] args) { Scanner keyboard; double priorBalance; double addtlCharges; double newBalance; double minPayment; // initialize needed variables here keyboard = new Scanner(System.in); // make sure that the number entered is a double and if so read it in. // if not, use a default value of zero. No error message to the user. System.out.print("Type the balance: "); priorBalance = keyboard.nextDouble(); if (keyboard.hasNextDouble() == true) { interestRate = 0.0; } else { interestRate = 0.02; } // make sure that the number entered is a double and if so read it in. // if not, use a default value of zero. No error message to the user. System.out.print(" Type the new charge amount: "); addtlCharges = keyboard.nextDouble(); // perform the calculation of interest, new balance and minimum payment newBalance = calculateInterest(priorBalance, addtlCharges); minPayment = calculateMinPayment(newBalance); // output the resulting statement (DO NOT CHANGE) System.out.println(" "); System.out.println("CS CARD International Statement"); System.out.println("==============================="); System.out.printf("Previous balance: $%,8.2f ", priorBalance); System.out.printf("Additional charges: $%,8.2f ", addtlCharges); System.out.printf("Interest: $%,8.2f ", interest); System.out.printf("New balance: $%,8.2f ", newBalance); System.out.printf("Minimum payment: $%,8.2f ", minPayment); } /** * This method will take in the previous balance and * additional charges and compute the amount of interest. * If the priorBalance is 0 or less, the interest is 0. * If there was a priorBalance, the interest is 2% of the * priorBalance plus the additional charges. * * @param priorBalance balance before the new charges are added * @param addtlCharges charges added this month * @return amount of interest to charge */ public static double calculateInterest(double priorBalance, double addtlCharges) { // first create a stub and get the input and output working // then replace the stub later on with the calculation interest = (priorBalance + addtlCharges) * interestRate; return interest; } /** * This method will take in the previous balance and * additional charges and compute the minimum payment. * $0.00 for new balance less than $0 * new balance for new balance between $0 and $49.99 (inclusive) * $50.00 for new balance between $50 and $300 (inclusive) * 20% of the new balance for new balance over $300 * * @param balance after interest and charges are added * @return minimum payment amount */ public static double calculateMinPayment(double balance) { // first create a stub and get the input and output working // then replace the stub later on with the calculation if (newBalance < 0) { balance = 0; } if (newBalance >= 0 && newBalance = 50 && newBalance 300) { balance = (newBalance * 0.2) + newBalance; } return balance; } }