Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: Help

  1. #1
    rsjava24 is offline Member
    Join Date
    Jan 2010
    Posts
    23
    Rep Power
    0

    Smile Help

    Hello everyone! Just new to java. Can i ask anybody to pls answer this? How can I convert Stack into a java program? Thank you.

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Maybe I could if I knew what you were talking about.

  3. #3
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default

    yeah, here is teh codez:
    Java Code:
    Stack = (Codez) new JavaProgram(1337);

  4. #4
    [RaIdEn] is offline Senior Member
    Join Date
    Oct 2009
    Location
    California,US
    Posts
    201
    Rep Power
    5

    Default

    Quote Originally Posted by quad64bit View Post
    yeah, here is teh codez:
    Java Code:
    Stack = (Codez) new JavaProgram(1337);
    lol,

    ok heres a tutorail and examples
    Stacks

  5. #5
    rsjava24 is offline Member
    Join Date
    Jan 2010
    Posts
    23
    Rep Power
    0

    Smile Stack Application

    Hehe;) thanks for reply..but anyway I need to see a sample of java program of converting infix-postfix and postix-infix using Stack Application. Any, reply will be appreciated. Thank you.:)

  6. #6
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    A "sample" program? A "sample" program would also, coincidentally, be 90%, or more, of the work required for your assignment.

    Instead of asking for a "sample" program, why don't you show us what you already have and explain, in detail, where the problem with it is.

  7. #7
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Why do you need that sample?
    So you can submit it in class as yours?

  8. #8
    rsjava24 is offline Member
    Join Date
    Jan 2010
    Posts
    23
    Rep Power
    0

    Smile Yes

    Yes sir. Not only i can submit to class but i need to study about it. Thank you.:)

  9. #9
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Better write your own code. That's the purpose of the assignment.
    So that you can learn to write Java code.
    We can help if you get stuck with your code.

  10. #10
    rsjava24 is offline Member
    Join Date
    Jan 2010
    Posts
    23
    Rep Power
    0

    Default

    ok but i don't know how to start it. ok I will try to start my own code maybe next time when i go to internet cafe again coz i am about to time's up. thanks for your time & talk to you soon again.

  11. #11
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Quote Originally Posted by rsjava24 View Post
    ok but i don't know how to start it. ok I will try to start my own code maybe next time when i go to internet cafe again coz i am about to time's up. thanks for your time & talk to you soon again.
    Start by understanding what infix and postfix is and how to convert between the two.
    Create some algorithms for the conversion (compare them against existing ones) and then convert the algorithms into a Java program.

  12. #12
    rsjava24 is offline Member
    Join Date
    Jan 2010
    Posts
    23
    Rep Power
    0

    Smile Stack Applocation

    Ok sir here I am again..this is the algorithm...

    this is an example given = (5 + 3 6) * (4 6 / 5 -)

    while stack is not empty
    if symbol is '('
    push
    else
    pop

    I have no idea how to convert this into a java program and run. Can somebody please give me an example? Thank you.:)

  13. #13
    rsjava24 is offline Member
    Join Date
    Jan 2010
    Posts
    23
    Rep Power
    0

    Default

    Hi masijade thanks for response. Anyway, I already sent my algorithm. Hope you can send me back an example java program. Thank you.

  14. #14
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Quote Originally Posted by rsjava24 View Post
    Ok sir here I am again..this is the algorithm...

    this is an example given = (5 + 3 6) * (4 6 / 5 -)

    while stack is not empty
    if symbol is '('
    push
    else
    pop

    I have no idea how to convert this into a java program and run. Can somebody please give me an example? Thank you.:)
    Look at the Stack class, and then try to implement your algorithm. Then, when you have problems with it, post your code here and we will help you correct it.

    Edit: I am not, however, implying that your algorithm is correct. You should study that a bit more.

  15. #15
    rsjava24 is offline Member
    Join Date
    Jan 2010
    Posts
    23
    Rep Power
    0

    Wink Stack Application

    Ok thank you.;)

  16. #16
    collin389 is offline Senior Member
    Join Date
    Nov 2009
    Posts
    235
    Rep Power
    5

    Default

    This is a helpful site for the conversion algoritham:
    Infix to Postfix Conversion

  17. #17
    rsjava24 is offline Member
    Join Date
    Jan 2010
    Posts
    23
    Rep Power
    0

    Default Inifx-Postfix

    Oh thank you Collin..this is a big help.

  18. #18
    rsjava24 is offline Member
    Join Date
    Jan 2010
    Posts
    23
    Rep Power
    0

    Default Stack-Queue

    Anyways this is a Stack.java code & how cAN i make this a Queue.java & add a length method in a Queue? There's a little bit differences between Stack & Queue my Prof said. Thank you.



    public class Stack {

    private Node top;


    public Stack() {

    top = new Node('J');


    }


    public void push(char c) {

    Node n = new Node(c);
    n.setNext(top.getNext());
    top.setNext(n);


    }


    public boolean isEmpty() {

    return top.getNext() == null;


    }


    public char pop() {

    char c = top.getNext().getValue();
    Node n = top.getNext();
    top.setNext(n.getNext());
    n.setNext(null);

    return c;


    }


    public char peek() {

    return top.getNext().getValue();



    }


    class Node {


    private char value;
    private Node next;


    public Node(char c) {

    value = c;
    next = null;



    }


    public char getValue() {

    return value;


    }



    public void setNext(Node n) {


    next = n;



    }


    public Node getNext() {

    return next;


    }



    }




    }

  19. #19
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Well, just like you looked at the API for Stack, look at the API for Queue.

  20. #20
    rsjava24 is offline Member
    Join Date
    Jan 2010
    Posts
    23
    Rep Power
    0

    Smile Thanks

    Oh by the way what is API hehe:) & where can I look API for Queue? Thank you.

Page 1 of 2 12 LastLast

Posting Permissions

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