subject

Develop a Java program that deals with greatest common dominators GCDs of positive integers. GCD of two positive integers is the is the largest positive integer that divides each of those two integers. The program works with the following specifications: a. Write a java method getGCD takes as parameter two integers and returns their greatest common divisor. The GCD could be computed for any two positive numbers. If the one of the two integers (or both) is negative the method should return -1. a. 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 firstNumbersArray is for the first numbers in the entered pairs, and the second array secondNumbersArray is for the second numbers in the entered pairs. • The program should get the GCD of each pair by calling the method getGCD repeatedly and save the produced GCDs in a third single-dimensional array called GCDsArray. • 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.

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 13:30, jessicascott120305
In mmf2, what is the grid? a. a toolbar that lets you open libraries and use the objects in them in your games b. an object that creates the background or other scenery for a game c. a set of vertical and horizontal lines that are usually invisible in the play area d. a set of vertical and horizontal lines that are usually visible in the play area
Answers: 1
image
Computers and Technology, 21.06.2019 21:00, brockmorrison3468
Is it ok to use a does red wine clean the inside of a computer true or false
Answers: 2
image
Computers and Technology, 21.06.2019 21:30, karleebowling316
Asuccessful format string attack attempted to steal user account information by reading from unauthorized memory. answer the followings with proper explanation a)this attack will lead to violation of which security policies?
Answers: 2
image
Computers and Technology, 23.06.2019 09:30, ranmmm
The place where the extended axis of the earth would touch the celestial sphere is called the celestial
Answers: 1
You know the right answer?
Develop a Java program that deals with greatest common dominators GCDs of positive integers. GCD of...

Questions in other subjects:

Konu
Mathematics, 12.11.2020 21:30