Question: Use method overloading to design two methods and call them on demand. REQUIREMENTS The user input is always of the correct type ( input

 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!