Question
WRITE IN JAVA Project 4: NumbersAA.java Write two static methods that each take two integer parameters. One method should calculate and return the least common
WRITE IN JAVA
Project 4: NumbersAA.java
Write two static methods that each take two integer parameters. One method should calculate and return the least common multiple of those two values and the other method should calculate the greatest common divisor of those two values. The main method will ask the user for the two inputs and then output the results from each method call. The user should also be given the option of inputting a new set of numbers continuously. Have the program end when the user types a 0 for both values.
The least common multiple is the smallest value that both numbers can divide into. Such as LCM(12, 15) should return the number 60. The algorithm for calculating LCM can be done easiest by calculating the greatest common divisor first as there is a relationship between the two. Greatest common divisor is the highest number that can be evenly divided into both values. Such as GCD(12, 15) should return 3. Calling the GCD method from within the LCM method is required. To calculate the GCD, look up the Euclidean Algorithm on the internet.
Do not use the recursive method from the book. Do not copy from outside sources and do not look up already made methods to solve this.
Output Example (User input is marked with >>>. Everything else is what you print to the screen.)
This program will give you the least common multiple and the greatest common divisor of two numbers. Please enter the first number: (Enter 0 for both numbers to exit.)
>>> 6
Please enter the second number
>>> 4
The least common multiple is 12 and the greatest common divisor is 2.
This program will give you the least common multiple and the greatest common divisor of two numbers. Please enter the first number: (Enter 0 for both numbers to exit.)
>>> 0
Please enter the second number
>>> 0
Goodbye.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started