r115 / java-learning-with-derrick

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction to Java: Methods with Parameters

A java method has 6 components.

  • modifier (public,private, protected, default)
  • return type
  • method name
  • parameter list
  • exception list
  • method body
public float payCarBalance(float currentBalance, float monthlyRate, User currentUser, float amount){
    // Reduce current blance
        float updatedBalance = currentBalance - amount;
        
        return updatedBalance;
}

A method parameter must always have a type.

Preferred naming is in camelcase.

Recommended reading

Practise

  • Attempt to apply a commission to the exchanged funds. A commission is calaculated as a percentage of the converted amount. The commission is then deducted from the converted amount. Allow the convert method to use a flexible commission rate.

Previous Classes

To access the code;

git fetch

git checkout day-3-static-variables-and-scope

About


Languages

Language:Java 100.0%