Guest User

Untitled

a guest
Oct 21st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2. public class GCFAssignment
  3. {
  4.             public static int InputInt(String S) // taken straight from my personally written methods.java -- only put in here for the sake of completeness, it's not in the final version of my program
  5.         {
  6.                 int x = Integer.parseInt(JOptionPane.showInputDialog(S));
  7.                 return x;
  8.         }
  9.     public static int GCF(int Int1, int Int2)
  10.     {
  11.             if (Int2 == 0) {
  12.                 return Int1;
  13.             }
  14.             return GCF(Int2, Int1 % Int2);
  15.         }
  16.    
  17.     public static void main(String[] args)
  18.     {
  19.         String pd = ".";
  20.         int x = methods.InputInt("Enter a positive integer.");
  21.         int y = methods.InputInt("Enter another positive integer.");
  22.         int GRCF = GCF(x, y);
  23.         System.out.println("The GCF of "+x+" and "+y+" is "+GRCF+pd);
  24.     }
  25. }
Add Comment
Please, Sign In to add comment