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

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
3
7
11
Expected Output:
add(a,b) = 10
add(a,b,c) = 21
Normal case
Input:
10
20
30
Expected Output:
add(a,b) = 30
add(a,b,c) = 60

Your Solution

Current Mode: My Code
Calculator.java🔒
Main.java🔒
2/6 ファイル95B
⚠️警告
  • No main method found
import java.util.Scanner;

class Calculator {
}
0 B / 5 MB

You have 10 free executions remaining