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, 22.06.2019 00:10, MadiAbbott798
How does access indicates that a filter has been applied to a specific column
Answers: 1
image
Computers and Technology, 23.06.2019 04:31, caseypearson377
Acloud service provider uses the internet to deliver a computing environment for developing, running, and managing software applications. which cloud service model does the provider offer? a. iaas b. caas c. maas d. paas e. saas
Answers: 1
image
Computers and Technology, 23.06.2019 13:30, Gearyjames8
Anetwork security application that prevents access between a private and trusted network and other untrusted networks
Answers: 1
image
Computers and Technology, 24.06.2019 18:30, trevorhenyan51
Dereck works for long hours on his computer.  he frequently experiences physical strain by the end of the day because he does not follow an important rule of ergonomics with respect to the use of keyboards.  which of the following actions of dereck could lead to physical strain? a.  placing the keyboard exactly in front of him while typingb.  keeping hands and wrists straight while typingc.  using wrist pads throughout the dayd.  pounding at the keys on the keyboard while typinge.  resting his hands on the keyboard when he is not typing
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
Business, 26.01.2020 08:31