010-001-007

Method Overloading: Type Difference

Easy

Problem Description

method overloading: Type Difference

In this problem, you will create a program that defines two overloaded calculate methods—one accepting int arguments and one accepting double arguments—to compute the sum of each pair and display the result to standard output.

Learning Objective: Understand method overloading with different argument types

Create two calculate methods: one for integers and one for decimals. Define methods with the same name calculate, where one accepts two int parameters and the other accepts two double parameters.

Input

Line 1: Integer 1 (integer)
Line 2: Integer 2 (integer)
Line 3: Decimal 1 (decimal)
Line 4: Decimal 2 (decimal)

Output

Integer calc: [int1] + [int2] = [sum]
Decimal calc: [dec1] + [dec2] = [sum]

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