Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: guide me please

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Location
    Kiyawa
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default guide me please

    how to make this expression 2+6+85-9 with calculator in java?


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: guide me please

    Need more info, like is it a command line or GUI calculator, but there's not much anyone can do for you until you post some of your own code and ask specific questions about how to fix or improve it.

  3. #3
    Member
    Join Date
    Jul 2013
    Posts
    219
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default Re: guide me please

    Hello.
    If you want to evaluate arithmetic expressions you can directly parse the given expression into tokens and compute the answer.
    Another much better way is to convert the given expression from infix notation to postfix notation. And then evaluate the postfix notation. You will need to use stack data structure to accomplish this.

    Thanks,
    Syed.

  4. #4
    Junior Member
    Join Date
    Oct 2013
    Location
    Kiyawa
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: guide me please

    Yes it is a GUI calculator, and
    the code i use to add is :
    String a=jTextArea1.getText();
    Int ans=0;
    For (int i=0; i<a.length; i++) {
    if a.charAt(i)=="+") {
    double ans1=Integer.parseInt
    (a.substring(0,i))+Integer.pa
    rseInt(a.substring(i+1),a.length
    ()));
    try {
    JTextArea1.append("="+ans1);
    Cath (Exception e)
    {e.printstacktrace();
    }
    else
    If (.............continuosly for * -
    and /
    ..........like that above

Similar Threads

  1. Guide me
    By sushil_p87 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 3rd, 2013, 09:06 AM
  2. Please guide on how to create Interactive graphics !
    By viv941 in forum Java Theory & Questions
    Replies: 1
    Last Post: October 31st, 2012, 09:18 AM
  3. Pls guide me in advance java
    By deepaks50 in forum Java Theory & Questions
    Replies: 3
    Last Post: May 19th, 2011, 08:55 AM