Methods: Reusable Code Blocks

Methods = Reusable Recipes

Write once, use 100 times. No copy-paste.

static double ApplyDiscount(double bill) {
    if (bill > 500) return bill * 0.10; // 10% off
    return 0;
}
double d1 = ApplyDiscount(600); // 60
double d2 = ApplyDiscount(300); // 0
staticJust add it for now
doubleWhat method returns
ApplyDiscountMethod name
(double bill)Input parameter
returnSends value back

Quick Check ๐Ÿง 

Easy Q1: What keyword sends a value back from method?

Comments on Methods (0)

No comments yet. Be the first to share your thoughts!