So basically, I get the message that the variable discountPrice might not have been initialized, and I know that to fix that I have change it to double discountPrice = 0, but I dont know "WHY"! Can someone exlain to me why I need to do that for the discountPrice variable but not the other variables?
class Revenue{
  public static void main(String[]args){
    Scanner console = new Scanner(System.in);
    double revenue, price, quantity, discountPrice;
    //Appearently should have double discountPrice = 0 'here'.
    System.out.print ("Enter product price ");
    price = console.nextDouble();
    System.out.print ("Enter quantity ");
    quantity = console.nextDouble();
    revenue = price * quantity;
    if (revenue > 5000){
      discountPrice = revenue * 0.10;
      revenue = revenue - discountPrice;
    }
    System.out.print("Discount Price is " + discountPrice);
    System.out.print("\nNet revenue is " + revenue);
  }
}
 
    