008-003-010

Calling Methods from Other Methods

Easy

Problem Description

Calling Methods from Other Methods

In this problem, you will implement three methods: add, multiply, and calculate. The calculate method calls add and multiply internally and returns the result, which is then printed.

Learning Objective: Understand how to call one method from another method

Input

Read three integers x, y, z, one per line

Output

Print the result of calculate(x, y, z) on one line

Specifications

  • add(int a, int b): returns a + b
  • multiply(int a, int b): returns a * b
  • calculate(int x, int y, int z): returns the result of multiplying add(x, y) with z

Example

Input:

2
3
4

Output:

20

(calculate(2, 3, 4)(2+3)*4 = 20)

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up