Results 1 to 3 of 3
  1. #1
    Priegelaar is offline Member
    Join Date
    Apr 2013
    Rep Power

    Default Parse input from console

    Hey everyone

    I am VERY new to Java. I do have experience with Javascript/html/css/sql/php and C#.

    So I want to make a calculator and the user has to type the command by himself
    Java Code:
    calc> 15+9
    By the user input I have to deliver the outcome, which will be 24.
    I know how to make a switch case or if-iterations to decide wheter it has to count/divide/...
    But the problem I have is to parse the input from the user
    I want to parse the input into number1 = 15, operation ="+" and number2="9".
    How do I solve this?

    Extended question: how do I solve this:
    Java Code:
    calc> 15+8+4+6+8

    Thanks in advance

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Tucson, AZ
    Rep Power

    Default Re: Parse input from console

    Simple arithmetic calculators are a common introductory example for the topic of recursive descent parsers.
    Get in the habit of using standard Java naming conventions!

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Parse input from console

    One of my blog articles discusses a simple (but rather complete) expression parser and a couple of ways to evaluate an expression (an interpreter and a code evaluator).

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Replies: 10
    Last Post: 04-12-2011, 06:00 PM
  2. How to get input from Console
    By karma in forum New To Java
    Replies: 8
    Last Post: 08-13-2010, 09:32 PM
  3. who to take user input ,not by console...
    By Shyam Singh in forum New To Java
    Replies: 3
    Last Post: 06-13-2008, 10:09 PM
  4. how to take input from console in jsp
    By veena in forum New To Java
    Replies: 1
    Last Post: 05-06-2008, 04:39 AM
  5. Taking input from console
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-05-2007, 04:47 PM

Posting Permissions

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