Question: 1. A positive integer is called a self-divisor if every decimal digit of the number is a divisor of the number, that is the number
1. A positive integer is called a "self-divisor" if every decimal digit of the number is a divisor of the number, that is the number is evenly divisible by cach and every one of its digits. For example, the number 128 is a self- divisor because it is evenly divisible by 1, 2 and 8. However, 26 is not a self-diviser because it is not evenly divisible by the digit 6. Note that is not considered to be a divisor of any number, so any number onga digit is NOT a self-diviser. There are infinitely many self-divisors public class seltdivisor /param number the number to be tested Precondition number > 0 return true if every decimal digit of number is a divisor of number: falde otherwise public static boolean issel Divisor (int number 1 /* to be implemented in part(a) /** param atart starting point for values to be checked Precondition: start > 0 param num the size of the array to be returned Precondition: nun > 0 areturn an array containing the first mum integers 2 start that we self-divisees public static int n tirat Name: Divisoresint start, int num) 1 to be implemented in part(b) / // There may be fields, constructors, and methods that are not shown (a) Write method insefDivinor, which takes a positive integer as its parameter. This method rietums true if the number is a self-divisor, otherwise, it returns false Complete method issel Divisor below. /*.aparam number the number to be tested Precondition number > 0 Sreturn true if every decimal digit of number is a divisor of number, false otherwise public static boolean isseltdivisor (int number) (b) Write method first Numsel Divisors, which takes two positive integers as parameters, representing a start value and a number of values. Method FirstBlumel Divisors retums an array of sure un that contains the first num self-divisors that are greater than or equal to start. For example, the call firstNumsel Divisorn (10. 3) should return an array containing the values 11, 12, and 15, because the first three self-divisors that are greater than or equal to 10 are 11, 12 and 15. In writing first Numsel Divinors, assume that issel Divisor works as specified, regardless of what you wrote in part(a) Complete method firstNumsel Divisors below. /** sparam start starting point for values to be checked Precondition: start > aparam num the size of the array to be returned areturn an array containing the first num integer 2 start that are self-divisos public static int tl first. NumSel Divisors(int start, int sum) 1. A positive integer is called a "self-divisor" if every decimal digit of the number is a divisor of the number, that is, the number is evenly divisible by each and every one of its digits. For example, the number 128 is a self- divisor because it is evenly divisible by 1, 2 and However, 26 is not a self-divisor because it is not evenly divisible by the digit 6. Note that is not considered to be a divisor of any number, so any number containing a digit is NOT a self-divisor. There are infinitely many self-divisor publie clann Self Divisor /* param number the number to be tested Precondition: number > 0 return true if every decimal digit of number is a divisor of number: false otherwise public static boolean fase divisor (int number to be implemented in part(a) / } /** uparan start starting point for values to be checked Precondition: start > aparan num the sure of the way to be returned Precondition: nuo return an amay containing the first num integers 2 start that are that are self-divisors public statie int! Sretalamse 1 Divinoratint start, int num) /. to be implemented in part(b) /> // There may be fields, constructors, and methods that are not shown. (a) Write method is selfdivisor, which takes a positive integer as its parameter. This method returns true if the number is a self-divisor, otherwise, it returns taise. Complete method 1sSelfDivisor below & how do you get the 1, 2 and 8? param number the number to be tested Precondition: number > 0 return true if every decimal digit of number is a divisor of number, false otherwise public static boolean iaSeleDivisor (int number) (b) Write method first.NumselfDivisors, which takes two positive integers as parameters, representing a start value and a number of values. Method first.Numsel Divisors retums an array of size num that contains the first num self-divisors that are greater than or equal to start For example, the call tiratrumsel Divinora (20. 3) should return an array containing the values 11.12 and 15 because the first three self-divisors that are greater than or equal to 10 are 11.12 and 15. In writing firatNumsel Divisors, assume that isSel Divisor works as specified, regardless of what you wrote in part(a) Complete method firstNumsel Divisore below sparan start starting point for values to be checked Precondition: start > param num the size of the array to be returned Precondition: num > 0 Sreturn an array containing the first nu mum integen start that are self-divisors public statie intl FirstNumsel Divisora int start, int num)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
