Question: Write a method int maxProductOfThree ( ) in a class ProductCalculator that finds the maximum product of largest three distinct numbers in a given array.
Write a method int maxProductOfThree in a class ProductCalculator that finds the
maximum product of largest three distinct numbers in a given array.
Create two classes: ProductCalculator and TestMain.
In the TestMain class:
Create an array of size
Use Scanner to input numbers into the array.
Create an object of the ProductCalculator class and call the
maxProductOfThree method using this object.
Print the maximum product of three largest distinct numbers.
Sample Test cases:
Enter the values:
The maximum product of three distinct numbers is:
Explanation: The maximum product is obtained from the numbers and
Enter the values:
The maximum product of three distinct numbers is:
Explanation: The maximum product is obtained from the numbers and
Enter the values:
The maximum product of three distinct numbers is:
Explanation: The maximum product is obtained from the numbers and
Grading Policy
Creating classes, object, declaring necessary variables and calling of the method
using object points
Creating method with array and logic points
Correct output without any errors points
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
