Question: Create a program using Java that lists the greatest common dominators of positive integers. a. Use method Gfinder to get the GCD of 2 integers

 Create a program using Java that lists the greatest common dominators

of positive integers. a. Use method Gfinder to get the GCD of

Create a program using Java that lists the greatest common dominators of positive integers. a. Use method Gfinder to get the GCD of 2 integers and return their GCD. If one of the 2 integers is less than 0 this method shall return -1. b. In the main method, the program reads from the user the number of pairs of integers to get GCD of each pair. According to the number of pairs, the program prompts the user to enter pairs of integers and saves these numbers in 2 single-dimensional arrays; the first array leqArray is for the first numbers in the entered pairs, and the second array leggArray is for the second numbers in the entered pairs. The program should get the GCD of each pair by calling the method Gfinder repeatedly and save the produced GCDs in a third single-dimensional array called resultArray The program should count the number of positive pairs that it could compute their GCD. Finally, the program should print all the entered pairs with their GCD and the ratio of the pairs with positive GCDs compared to all entered pairs. 11 11 II 11 11 Il = 11 11 11 = II 11 = II II 11 11 II II 11 11 Sample Run: run: Enter number of pairs of integers: 6 Enter two integers: 44 33 Enter two integers: 24 16 Enter two integers: -8 6 Enter two integers: 50 35 Enter two integers: 9-5 Enter two integers: 12 8 RESULTS >>>>>>>>> GCD (44,33) = 11 GCD (24,16) 8 GCD (-8,6) -1 GCD (50,35) = 5 GCD (9,-5) = -1 GCD (12,8) = 4 Number of positive GCDs = 4 with ratio 66.67% BUILD SUCCESSFUL (total time: 29 seconds)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!