Modifty the Cash Register Class to create a file containing a sales receipt. The program should ask the user for the quantity of the items being purchased and then generate a file with contents to similar to the following:

SALES RECEIPT
UNIT PRICE: 10.00
QUANTITY: 5
SUBTOTAL: 50
SALES TAX: 3
TOTAL: 53

public class CashRegister
    {
        private RetailItem retailItem;
        private int quantityItems;
        private final double SALES_TAX = .06;
        private int subTotal;
        private double price;



        public CashRegister ()
        {
            quantityItems = 0;
            subTotal = 0;
        }


       public CashRegister(RetailItem retailObject, int quantity)
       {
          price = retailObject.getPrice();

          quantityItems = quantity;

          subTotal = sub;

       }



        public RetailItem getRetailItem()
        {

            return new RetailItem();
        }

        public double getSubTotal()
        {
            return quantityItems * retailItem.getPrice();
        }

        public double getTax()
        {
            return SALES_TAX;
        }


        public double getTotal()
        {
            return subTotal + SALES_TAX;
        }

        public String toString()
        {
            return " Unit Price:" + getPrice() + "Quantity:" + quantityItems + "SubTotal" + getSubTotal
                     + " Sales Tax" + getTax() + " Total" + getTotal();
        }
    }




import java.util.Scanner;

public class SalesReceipt
{
    public static void main (String [] args)
    {

        CashRegister yourRegister = new CashRegister(null, 5);


        Scanner keyboard = new Scanner(System.in);

        System.out.println(" How much quantity is being purchased: " );
            quantityItems = keyboard.nextInt();


    }
}

hmmm... I thought it seemed familiar..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.