java
CS219- Lab01 Wiemann
Requirements: 1) Create a Java Program to calculate the greatest common divisor (GCD) for
two inputted integers.
2) The greatest common divisor of two integers a and b, GCD(a, b), not both of which are zero, is the largest positive integer that divides both a and b. The Euclidean algorithm for finding this greatest common divisor of a and b is as follows:
1) Divide a by b to obtain the integer quotient q and remainder r, so that a = bq + r.
2) If b = 0, GCD(a, b) = a, otherwise GCD(A, b) = GCD(B, r). (i.e. replace a with b and b with r and repeat this procedure)
3) Since the remainders are decreasing, eventually a remainder of 0 results. The last nonzero remainder is GCD(a, b). For example:
1260 = 198 * 6 + 72 GCD(1260, 198) = GCD(198, 72)
198 = 72 * 2 + 54 = GCD(72, 54)
72 = 54 * 1 + 18 = GCD(54, 18)
54 = 18 * 3 + 0 = 18
3) All shop standards are to be followed as instructed in class.
4) The calculation of the GCD must be inside of a function contained in the class
you have created.
5) Validation of input must occur on the input of the typed data (i.e. ‘12B’ is not a valid decimal value). An error message should be displayed to the end user if the required menu option is not valid.
6) Save the source code as “mrwJavaProg01.java”.
7) You will submit the source code/Java file to the Dropbox for this assignment on or before the due date.