You are on page 1of 1

Java Calculator Class with Method Overloading

Objective:
Create a Java class named Calculator that implements basic arithmetic operations and
utilizes method overloading.
Requirements:

1. Class Structure:

• The Calculator class should have the following methods:


• add method that takes two integers as parameters and returns their sum.
• subtract method that takes two integers as parameters and returns the result of
subtracting the second integer from the first.
• multiply method that takes two integers as parameters and returns their product.
• divide method that takes two integers as parameters and returns the result of dividing
the first integer by the second.

2. Method Overloading:

• For add:
➢ Overload the add method to handle addition of three integers.
• For subtract:
➢ Overload the subtract method to handle subtracting three integers.
• For multiply:
➢ Overload the multiply method to handle multiplying three integers.

3. Input/Output:

• Create a main method in a separate class to test the functionality of the Calculator
class.
• Instantiate an object of the Calculator class and demonstrate the use of each method
with different sets of values.
• Display the results of each operation.

4. Create Test for each method

Note: Ensure appropriate error handling for division by zero.

You might also like