divider

Objective

Demonstrate proficiency in defining and invoking functions with parameters and return values by solving practical math and logic problems.

These challenges are language-agnostic, meaning they can be completed in any programming language. Make sure to use the proper conventions for your chosen language.

Skills to Practice

  • icon Defining and calling functions with parameters
  • icon Using return statements to send values back to the caller
  • icon Applying mathematical formulas inside functions
  • icon Using void and non-void functions correctly
divider

Tasks

  • icon Create a new project named Application-3-1
  • icon Complete the following function challenges:
    • icon 1. Convert Inches to Centimeters: Write a function named inchesToCm() that takes one float or double parameter parameter (inches) and returns the equivalent length in centimeters.
    • icon 2. Find the Maximum of Two Numbers: Write a function named max() that takes two integer parameters and returns the larger of the two values.
    • icon 3. Calculate the Area of a Circle: Write a function named circleArea() that accepts a float or double parameter radius parameter and returns the area of a circle using Math.PI.
    • icon 4. Determine if a Number is Even: Write a function named isEven() that accepts an integer and returns true if it's even or false if it's odd.
    • icon 5. Convert Fahrenheit to Celsius: Write a function named toCelsius() that converts a float or double parameter Fahrenheit temperature to Celsius using the formula (F - 32) * 5 / 9.
    • icon 6. Calculate the Average of Three Numbers: Write a function named averageOfThree() that accepts three float or double parameter parameters and returns their average.
divider

Sample Output

Sample Output
Inches to Centimeters: 12.7
Max of (8, 3): 8
Area of Circle (r=3): 28.27
Is 7 even? false
98.6°F in Celsius: 37.0
Average of (5, 7, 9): 7.0

Begin Challenge