Question
A. Write a boolean method named isPerfectNumber that accepts a single positive integer parameter and returns a boolean. A Perfect Number is any integer that
A. Write a boolean method named "isPerfectNumber" that accepts a single positive integer parameter and returns a boolean. A "Perfect Number" is any integer that is the sum of all its proper factors (that is, factors including 1 but not the number itself). The first two perfect numbers are 6 and 28, since 1+2+3=6 and 1+2+4+7+14=28 See Wikipedia (Links to an external site.)Links to an external site. if you need to know more.
B. Write a method named random4DigitNum that returns an int of exactly 4 digits [1000,9999]. For example, the call of random4DigitNum() might return 1234 or eventually could return 9281 as both are 4 digit int's. Note that integers such as 341 and 12 as return values are not acceptable.
Upload Chapter5.java with solutions to below: A. Write a boolean method named "isPerfectNumber" that accepts a single positive integer parameter and returns a boolean. A "Perfect Number" is any integer that is the sum of all its proper factors (that is, factors including 1 but not the number itself). The first two perfect numbers are 6 and 28, since 1+2+3-6 and 1+2+4+7+14-28 See Wikipedia if you need to know more. B. Write a method named random4DigitNum that returns an int of exactly 4 digits [1000,9999. For example, the call of random4Digi tNum might return 1234 or eventually could return 9281 as both are 4 digit int's. Note that integers such as 341 and 12 as return values are not acceptable. Reminder: You could get 20 points just for submitting the correct Class name, and correct 1,2,3 (return, name, parameters) for each method. And here's a main) method for Chapter4.java that will work if you do this correctly: public static void main StringC] args) // A. Is Perfect Number ??? int test = 0; while (test 999) if CisPerfectNumber(test)) System.out.println(test); // 6 and 28 test++; //B. Random Four Digit Number do test = random4DigitNum(); } while (test-1313); System.out.println(test); 11 1313
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