Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started