Use method overloading to design two methods and call them on demand. REQUIREMENTS The user input
Fantastic news! We've Found the answer you've been seeking!
Question:
Use method overloading to design two methods and call them on demand.
REQUIREMENTS
- The user input is always of the correct type (input verification is not required).
- All numbers and computation results are all assumed to be in int type.
- The method calculateMultiplication() is to be overloaded. The first one takes 2 int type arguments as input and returns 1 int type value (the result of the multiplication of the 2 numbers), the second one takes 3 int type arguments and returns 1 int type value (the result of the multiplication of the 3 numbers).
- The method main()is to call one of these two overloaded methods according to the user input, or report invalid input.
- Your code must work as the following example (the text in bold indicates the user input
Example of the program output:
Example 1:
Would you like to enter 2 numbers or 3? 1
Your input is invalid.
Example 2:
Would you like to enter 2 numbers or 3? 2
Enter the first number: 6
Enter the second number: 3
6 x 3 = 18
Example 3:
Would you like to enter 2 numbers or 3? 3
Enter the first number: 5
Enter the second number: 10
Enter the third number: 2
5 x 10 x 2 = 100
Posted Date: