Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class GCFAssignment
- {
- 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
- {
- int x = Integer.parseInt(JOptionPane.showInputDialog(S));
- return x;
- }
- public static int GCF(int Int1, int Int2)
- {
- if (Int2 == 0) {
- return Int1;
- }
- return GCF(Int2, Int1 % Int2);
- }
- public static void main(String[] args)
- {
- String pd = ".";
- int x = methods.InputInt("Enter a positive integer.");
- int y = methods.InputInt("Enter another positive integer.");
- int GRCF = GCF(x, y);
- System.out.println("The GCF of "+x+" and "+y+" is "+GRCF+pd);
- }
- }
Add Comment
Please, Sign In to add comment