mardi 26 septembre 2017

How to create a valid return statement in a method

I have a method called CalculateSimpleInterest () that calculates the interest according to the season type. Its return type is double . How to make it work correctly. I have a code that is throwing compile time error saying you need a valid return statement.

   public double calculateSimpleInterest(){
    if (seasontype == SeasonType.SUMMER){
        return (principal * years * 0.08);
    }
    else if (seasontype == SeasonType.WINTER){
        return(principal *years * 0.07);
    }

    else if (seasontype == SeasonType.AUTUMN){
        return (principal * years * 0.075);
    }
} 

Aucun commentaire:

Enregistrer un commentaire