1. Using get() to read multiple keyboard input

I'm curious to know whether it's possible to use get() in this situation:
1   ask user to type some numbers, each separated by a space
2   enter the whole set of numbers
3   read the numbers      -- can you use get() here?
4   compute their average
5   display the average to screen

The point of my query is that get() has to be issued separately for each
number - which is OK if you know beforehand how many numbers the user will
enter. If the choice is left up to the user (so it may vary at each program
run), is it possible to write code that can "sense" how many numbers have
been entered? This value could then be used to call get() the required
number of times.

Thank you

Alex Caracatsanis

new topic     » topic index » view message » categorize

2. Re: Using get() to read multiple keyboard input

------------100721A1637825C

> I'm curious to know whether it's possible to use get() in this situation:
> 1   ask user to type some numbers, each separated by a space
> 2   enter the whole set of numbers
> 3   read the numbers      -- can you use get() here?
> 4   compute their average
> 5   display the average to screen

> The point of my query is that get() has to be issued separately for each
> number - which is OK if you know beforehand how many numbers the user will
> enter. If the choice is left up to the user (so it may vary at each program
> run), is it possible to write code that can "sense" how many numbers have
> been entered? This value could then be used to call get() the required
> number of times.

> Thank you

> Alex Caracatsanis

It is not possible to use get() to read in a list of numbers seperated
by spaces, you could allow the user to enter the numbers like a
sequence "{1,2,3,4,5}".

I have attached an example program that allows the user to enter any
amount of numbers seperated by spaces (or commas) then prints the
avarge.
Thomas Parslow (PatRat) ICQ #:26359483
Rat Software
http://www.ratsoft.freeserve.co.uk/
Please leave quoted text in place when replying
------------100721A1637825C

new topic     » goto parent     » topic index » view message » categorize

3. Re: Using get() to read multiple keyboard input

------=_NextPart_000_009F_01C00C66.6955C4C0
        charset="iso-8859-1"

errrrr patrat...
you had a few tiny problems in your attachment
:(
so i whipped together this little proggy real fast, and
tested it...
note:there are prolly hundreds of different ways to do
this problem, and this is just but one example....
enjoy!--Hawke'

> > I'm curious to know whether it's possible to use get() in this
situation:
> > 1   ask user to type some numbers, each separated by a space
> > 2   enter the whole set of numbers
> > 3   read the numbers      -- can you use get() here?
> > 4   compute their average
> > 5   display the average to screen



------=_NextPart_000_009F_01C00C66.6955C4C0
        name="average.ex"
Content-Transfer-Encoding: quoted-printable

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu