Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #23385

Re: Inserting Multiple Lines from Console

From markspace <markspace@nospam.nospam>
Newsgroups comp.lang.java.programmer
Subject Re: Inserting Multiple Lines from Console
Date 2013-04-08 09:56 -0700
Organization A noiseless patient Spider
Message-ID <kjusns$tqr$1@dont-email.me> (permalink)
References <e88303ce-910f-4aad-af1a-895ce3ca4a8b@googlegroups.com>

Show all headers | View raw


On 4/8/2013 6:59 AM, subhabangalore@gmail.com wrote:

> I was trying to get input of different nature of string, int etc.

> It is generally going okay but when the output is being generated I
> am getting arbitrary output.

I think first your main problem is trying to define the problem.  You 
need to define what "nature" you want to read in what circumstances. 
Nobody just reads lines and turns them into strings or ints on a whim.

If you need some definition because your just doing this on your own, 
consider writing a simple parser for algebraic input.  Parsers are 
common in computer science, so they're good to know about, look it up.

The next step is to define some test cases.  Here's some lines you 
should be able to read in and parser correctly.  Note that I'm assuming 
you'll do this "algebraically" and that * and / get evaluated before + 
and -.

1 + 1
-10
1243 + 678 * 5
1 / 3
45 - 34 + 12 - 90 + 78 * 3 / 2

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Inserting Multiple Lines from Console subhabangalore@gmail.com - 2013-04-08 06:59 -0700
  Re: Inserting Multiple Lines from Console Joerg Meier <joergmmeier@arcor.de> - 2013-04-08 17:04 +0200
    Re: Inserting Multiple Lines from Console Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-04-08 14:10 -0700
      Re: Inserting Multiple Lines from Console Lew <lewbloch@gmail.com> - 2013-04-08 15:10 -0700
        Re: Inserting Multiple Lines from Console x@x.com (znôrt) - 2013-04-09 01:08 +0200
          Re: Inserting Multiple Lines from Console Lew <lewbloch@gmail.com> - 2013-04-08 17:59 -0700
            Re: Inserting Multiple Lines from Console x@x.com (znôrt) - 2013-04-09 08:46 +0200
            Re: Inserting Multiple Lines from Console Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-04-09 05:39 -0300
              Re: Inserting Multiple Lines from Console Martin Gregorie <martin@address-in-sig.invalid> - 2013-04-09 23:04 +0000
              Re: Inserting Multiple Lines from Console x@x.com (znôrt) - 2013-04-10 19:45 +0200
                Re: Inserting Multiple Lines from Console Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-10 14:43 -0400
                Re: Inserting Multiple Lines from Console Gene Wirchenko <genew@telus.net> - 2013-04-11 11:11 -0700
                Re: Inserting Multiple Lines from Console Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-11 15:05 -0400
  Re: Inserting Multiple Lines from Console lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-08 16:21 +0100
  Re: Inserting Multiple Lines from Console markspace <markspace@nospam.nospam> - 2013-04-08 09:56 -0700
  Re: Inserting Multiple Lines from Console lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-04-09 08:28 +0100

csiph-web