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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 03:30
Some of your friends have gotten into the burgeoning field of time-series data mining, in which one looks for patterns in sequences of events that occur over time. purchases at stock exchanges--what’s being bought-- are one source of data with a natural ordering in time. given a long sequence s of such events, your friends want an efficient way to detect certain "patterns" in them--for example, they may want to know if the four events buy yahoo, buy ebay, buy yahoo, buy oracle occur in this sequence s, in order but not necessarily consecutively. they begin with a collection of possible events (e.g., the possible’ transactions) and a sequence s of n of these events. a given event may occur multiple times in s (e.g., yahoo stock may be bought many times in a single sequence s). we will say that a sequence s’ is a subsequence of s if there is a way to delete certain of the events from s so that the remaining events, in order, are equal to the sequence s’. so, for example, the sequence of four events above is a subsequence of the sequence buy amazon, buy yahoo, buy ebay, buy yahoo, buy yahoo, buy oracle their goal is to be able to dream up short sequences and quickly detect whether they are subsequences of s. so this is the problem they pose to you: give an algorithm that takes two sequences of even~s--s’ of length m and s of length n, each possibly containing an event more than once--and decides in time o(m n) whether s’ is a subsequence of s
Answers: 2
question
Computers and Technology, 22.06.2019 10:00
What is a society that has moved to the internet rather than relying on physical media called
Answers: 2
question
Computers and Technology, 22.06.2019 18:00
Suppose an astronomer discovers a large, spherical-shaped body orbiting the sun. the body is composed mostly of rock, and there are no other bodies sharing its orbit. what is the best way to categorize this body? a. planet b. moon c. comet d. asteroid
Answers: 1
question
Computers and Technology, 23.06.2019 14:00
Technician a says that with self-adjusting clutch systems, the release bearing constantly rotates. technician b says that the ball bearing portion of the release bearing should be lubricated with high-temperature grease during routine maintenance. which technician is correct?
Answers: 2
You know the right answer?
Develop a Java program that deals with greatest common dominators GCDs of positive integers. GCD of...
Questions
question
Social Studies, 25.12.2019 03:31
question
Mathematics, 25.12.2019 03:31
question
Mathematics, 25.12.2019 03:31
question
Mathematics, 25.12.2019 03:31
question
Mathematics, 25.12.2019 03:31