Hai, can anyone help me?
missing return statement error keep appear when i tried to run this code

class CoffeeBags{
    //Data member
    private static final double PRICE_PER_LB = 5.99;
    private static final double TAX_RATE = 0.0725;
    private int numberOfBags;
    private double totalPrice;
    private double totalPriceWithTax;
    private int bagWeight;

    //constructor
    public CoffeeBags (double totalPrice, double totalPriceWithTax){
        //double totalPrice=0.0;
    }


    //get method
    public double getTotalPrice(){

        return totalPrice;
    }

    public double getTotalPriceWithTax(){
        return totalPriceWithTax;
    }

    //set method
    public double settotalPrice(){
        totalPrice = bagWeight * numberOfBags * PRICE_PER_LB;
    }

    public double settotalPriceWithTax(){
        totalPriceWithTax = totalPrice + totalPrice * TAX_RATE;
    }
}

Methods settotalPrice() and settotalPriceWithTax() are both type double, but neither one has a return statement.

Your set methods (settotalPrice() and settotalPriceWithTax()) should be of the type void

oh. Ok guys. I got it. TYVM!

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.