0

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();


    }
}
3
Contributors
2
Replies
5
Views
4 Years
Discussion Span
Last Post by stultuske
Featured Replies
  • 1

    Is this the same question: http://www.daniweb.com/software-development/java/threads/436236/sales-receipt-program-from-cash-register-program Please don't start a new thread for the same question Read More

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.