import javax.swing.*; public class ProblemD { // Uses Horner's Method to compute decimal value public static int convertFromBinaryToDecimal(String x) { int answer = 0; for (int i = 0; i <= x.length() - 1; ++i) { answer = answer * 2; answer += x.charAt(i) - '0'; } return answer; } // Uses Euclid's Algorithm to find GCD public static int gcd(int A, int B) { int r, q; while (A != 0) { q = B / A; r = B % A; B = A; A = r; } return B; } public static void main(String args[]) { String S1 = JOptionPane.showInputDialog("Enter S1"); String S2 = JOptionPane.showInputDialog("Enter S2"); int num1 = ProblemD.convertFromBinaryToDecimal(S1); int num2 = ProblemD.convertFromBinaryToDecimal(S2); int g = ProblemD.gcd(num1, num2); if (g == 1) { JOptionPane.showMessageDialog(null, "Love is not all you need!"); } else { JOptionPane.showMessageDialog(null, "All you need is love!"); } } }