Just started learning Java three days ago and am currently doing a problem in my textbook where I do some basic cash register functionality. So far my code canfactor in taxes, let the user get change, and tell them the amount the actual tax is.public class Register {    private double purchase;    private double payment;    private double tax;    public Register()    {    }    public Register(double tax)    {        this.tax = tax;    }    public void recordPurchase(double amount)    {        purchase = purchase + amount;    }    public void enterPayment(double amount)    {        payment = amount;    }    public void recordTaxablePurchase()    {        purchase = purchase  + (purchase *(tax/100));    }    public double getTotalTax()    {        return (purchase*0.10);    }    public void getSalesTotal()    {    }    public double giveChange()    {        double change = payment - purchase;        purchase = 0;        payment = 0;        return change;      }}Running itpublic class RegisterTest {    public static void main(String [] args)    {        Register pay = new Register(10);        pay.recordPurchase(100);        pay.recordTaxablePurchase();        pay.enterPayment(200);        double change = pay.giveChange();        System.out.println(change);    }   }Now the next part is to do:After closing time, the store manager would like to know how much business was transacted during the day. Modify the CashRegister class to enable this functionality. Supply methods getSalesTotal and getSalesCount to get the total amount of all sales and the number of sales. Supply a method reset that resets any counters and totals so that the next days sales start from zero.My thoughts: let's add two instance variables which should always be private:private double totalPurchase;private int count;Change recordPurchase to:public void recordPurchase(double amount)    {        purchase = purchase + amount;        totalPurchase = totalPurchase + amount;        count = count+1;    }Also do the same for tax.Then simply do:public double giveSalesTotal()    {        return totalPurchase;    }    public int getSalesCount()    {        return count;    }Does this seem like an ok way of doing it? It works, but seems really bad to create another new variable like totalPurchase, instead of using the original purchase.
Java Cash Register adding methods
java;beginner;finance