Question: 2. (25 minutes) (35 points) You will write three methods in this questions. The first method called inputGetter will check the input if it is
2. (25 minutes) (35 points) You will write three methods in this questions. The first method called inputGetter will check the input if it is a positive integer. It will ask for a new input until the user enters a positive integer and returns the valid integer N. Then, this integer N will be utilized as a parameter for the second method called prime Factorization. This method will get the number N and returns a two-dimensional array that shows the prime factors and how many times each factor exists in this number. The first element of the array will be the prime factor, the second element will show how many times this factor exists. Then, the last method print will get this array and prints all elements as exactly as it is shown in the output example runs. Example RUN 1: Example RUN 2: Please enter a number Please enter a number: 195 -12 The output array is: Please enter a positive integer 31 51 Please enter a positive integer. 131 100 Example RUN 3: The output array is: Please enter a number: 22 420 52 The output array is: 22 31 0 51 71 public static void main(String args) { System.out printin("Please enter a number:"); Scanner sc = new Scanner(System.in); int N=inputGetter(sc); int an00= prime Factorizationa(N): System.out println("The output array is:"); printarr): }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
