*Using Java
Perfect Numbers
We consider an integer number as a perfect number if its factors(including 1, but not the number itself) total up to the number.For example, 6 is a perfect number because its factors (excluding6) are: 1, 2, and 3, which total to 6.
Using Java, write a method (also known as functions in C++)named isPerfect that takes in oneparameter named number, and return aString containing the factors for the number that totals up to thenumber if the number is a perfect number. If the number is not aperfect number, have the method return a null string (do this witha simple: return null; statement).
Utilize this isPerfect method in a program that prompts the userfor a maximum integer, so the program can display all perfectnumbers from 2 to the maximum integer (be careful having the userpick a maximum integer bigger than 100000).
See the following screenshots of example test runs:
Figure 1. Perfect Numbers - User Enters 100, Program DisplaysPerfect Numbers From 2 To 100
Figure 2. Perfect Numbers - User Enters 100, Program DisplaysPerfect Numbers From 2 To 1000
Figure 3. Perfect Numbers - User Enters 100, Program DisplaysPerfect Numbers From 2 To 10000
Enter the largest number to try to display: 100 6 is perfect. Factors: 1 2 3 28 is perfect. Factors: 1 2 4 7 14 Enter the largest number to try to display: 1000 6 is perfect. 28 is perfect. 496 is perfect. Factors: 1 2 3 Factors: 1 2 4 7 14 Factors: 1 2 4 8 16 31 62 124 248 Enter the largest number to try to display: 10000 6 is perfect. 28 is perfect. 496 is perfect. 8128 is perfect. Factors: 1 2 3 Factors: 1 2 4 7 14 Factors: 1 2 4 8 16 31 62 124 248 Factors: 1 2 4 8 16 32 64 127 254 508 1016 2032 4064 Show transcribed image text Enter the largest number to try to display: 100 6 is perfect. Factors: 1 2 3 28 is perfect. Factors: 1 2 4 7 14