63 839
Assignments Done
99,2%
Successfully Done
In August 2018

Answer to Question #13972 in Java | JSP | JSF for aynalem

Question #13972
4.Write a program that accepts two numbers from the user and return the LCM of two numbers
Expert's answer
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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions