4.Write a program that accepts two numbers from the user and return the LCM of two numbers
import java.util.Scanner;
public class Test {
public static void
main(String[] args) {
double a = 0;
double b = 0;
Scanner s = new
Scanner(System.in);
System.out.println("Input numbers: ");
a =
s.nextDouble();
b = s.nextDouble();
double x = a;
double y =
b;
while (a != b) {
if (a > b)
a = a - b;
else
b = b -
a;
}
System.out.println("LCM= " + x * y / a);
}
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
JavaJSPJSF