I want to find the total amount of payment, but when I compile and run the code, I get this error
Exception in thread "main" java.lang.NullPointerException.
payment class
package tutorial3;
    public class Payment {
        private double amount;
        public Payment()
        {
         this(0.0);
        }
        public Payment(double amount)
        {
         setAmount(amount);
        }
        public void setAmount(double amount)
        {
            this.amount = amount;
        }
        public double getAmount()
        {
            return amount;
        }
        public String toString()
        {
            return "amount paid is " + getAmount();
        }
    }
main class:
 public class main {
        public static void main(String[] args){   
            Payment [] p = new Payment[2];
            Scanner sales = new Scanner (System.in);
            double total = 0;
            for(int i=0; i<3; i++)
            {
             System.out.print("Sales amount? ");
             double amt = sales.nextInt();
             Payment cash = new Payment(amt);
            }        
            for( Payment pv : p  ){
                total += pv.getAmount();
            }
        }      
    }
 
     
     
    