Results 1 to 5 of 5
  1. #1
    oshiru is offline Member
    Join Date
    Nov 2008
    Location
    Sri Lanka
    Posts
    2
    Rep Power
    0

    Default need an interface for a recursion algorithm program

    i need some help to finish my assignment
    following is the code
    i want the main method to get an user input, it should be a GUI, since i don;t know swing i find it hard , please help me.. regards.. i want the interface to get a single integer and buttons to compute, factorial, triangle and partaily by giving a nother value to compute permutation or combination

    import java.io.*;
    class fcp
    {
    int factorialGen(int x){

    int temp;
    if(x==0){
    temp=1;
    }else if(x==1){
    temp=1;
    }else{
    temp=x*factorialGen(x-1); //recurtion of function;
    }
    return temp;
    }

    int combination(int n,int r){
    int x = factorialGen(n)/(factorialGen(r)*factorialGen(n-r));
    return x;
    }

    int permutation(int n,int r){
    int x = factorialGen(n)/factorialGen(r);
    return x;
    }

    void triangle(int x){
    for(int n=0;n<=x;n++){
    for(int j=x;j>=0;j--){
    System.out.println(" ");
    }
    for(int r=0;r<n;r++){
    combination(n,r);
    }

    }
    System.out.println("\n");

    }

    void pascalTrianglefactorial(int x){

    System.out.println("The factorial value is"+factorialGen(x));
    triangle(x);
    }
    Last edited by oshiru; 11-25-2008 at 04:55 PM. Reason: title doesn't match for what i require

  2. #2
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    6

    Default

    Create JFrame ,add to it JPanel which will have JButton and JTextField,and add to the action listeners,which will produce and operate all the functions you need.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  4. #4
    oshiru is offline Member
    Join Date
    Nov 2008
    Location
    Sri Lanka
    Posts
    2
    Rep Power
    0

    Default

    thnx alot guys..im absolutely new for this field

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. Recursion in Java ..
    By Java01 in forum New To Java
    Replies: 6
    Last Post: 10-24-2008, 11:42 AM
  2. java recursion infinite loop
    By tony404 in forum Advanced Java
    Replies: 9
    Last Post: 10-03-2008, 01:16 PM
  3. i could not get the recursion in java
    By sivasayanth in forum New To Java
    Replies: 3
    Last Post: 04-23-2008, 08:08 AM
  4. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  5. Recursion in java
    By lenny in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 06:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •