import java.util.Scanner; public class GCDProgram { public static void main(String[] args) { int length, width, gcd; boolean found; System.out.print("Enter the floor length (cm): "); length = new Scanner(System.in).nextInt(); System.out.print("Enter the floor width (cm): "); width = new Scanner(System.in).nextInt(); gcd = Math.min(length, width); found = false; while (!found) { if (((length%gcd) == 0) && ((width%gcd) == 0)) found = true; else gcd--; } System.out.println("You need (" + gcd + "cm x " + gcd + "cm) tiles."); } }