0

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;
    }
}

Edited by Reverend Jim: Fixed formatting

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by arawani
0

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

0

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

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.