010-001-006
Overloading Concept: Calculator
Medium
Problem Description
Overloading Concept: Calculator
In this problem, you will create a program that defines two add methods with the same name but different numbers of parameters, computes the sum of two integers and the sum of three integers respectively, and displays the results to standard output.
Learning Objective: Understand method overloading
Create a calculator class that uses the same add method name with different numbers of parameters.
Input
Line 1: Integer a
Line 2: Integer b
Line 3: Integer c
Output
add(a,b) = [a+b]
add(a,b,c) = [a+b+c]
Example
Input:
1
2
3
Output:
add(a,b) = 3
add(a,b,c) = 6
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