AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

newbie

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
Danny Gopie
Guest





PostPosted: Mon Nov 22, 2004 4:16 pm    Post subject: newbie Reply with quote



Hello

i want to write a program that reads an integer between 0 and 1000 and
summarizes all the digits in the integer. For example, if an integer is 932,
the sum of all the digita is 14.

Does anyone knows how to do this?

Danny



Back to top
Andrew Thompson
Guest





PostPosted: Mon Nov 22, 2004 4:29 pm    Post subject: Re: newbie Reply with quote



On Mon, 22 Nov 2004 17:16:31 +0100, Danny Gopie wrote:

Quote:
i want to write a program..

As I mentioned to you over on c.l.j.machine, please post this
question to c.l.j.help.

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane

Back to top
Fahd Shariff
Guest





PostPosted: Mon Nov 22, 2004 10:32 pm    Post subject: Re: newbie Reply with quote



you might have to convert the int to a string and then loop through the
chars in the String, converting each one into an int and adding:

int num = 932;
int sum = 0;
String s = Integer.toString(num);
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
int digit = Integer.parseInt(Character.toString(c));
sum += digit;
}
System.out.println(sum);

--
Fahd Shariff
http://www.fahdshariff.cjb.net
"Let the code do the talking... "

Back to top
Steven T Abell
Guest





PostPosted: Tue Nov 23, 2004 5:14 am    Post subject: Re: newbie Reply with quote

Danny Gopie wrote:

Quote:
Hello

i want to write a program that reads an integer between 0 and 1000 and
summarizes all the digits in the integer. For example, if an integer is 932,
the sum of all the digita is 14.

Does anyone knows how to do this?

Danny

Danny, by any chance, are you a *student*?
And is this an *assignment*?

Steve

Back to top
Thomas Weidenfeller
Guest





PostPosted: Tue Nov 23, 2004 8:32 am    Post subject: Re: newbie Reply with quote

Danny Gopie wrote:
Quote:
Hello

i want to write a program that reads an integer between 0 and 1000 and
summarizes all the digits in the integer. For example, if an integer is 932,
the sum of all the digita is 14.

This does not only awfully smell like homework, but it has absolutely
nothing to do with GUI development. Why do you post here?

/Thomas

--
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq

Back to top
Andrew Thompson
Guest





PostPosted: Tue Nov 23, 2004 9:31 am    Post subject: Re: newbie Reply with quote

On Tue, 23 Nov 2004 09:32:32 +0100, Thomas Weidenfeller wrote:

Quote:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq

That's cool! (First time I'd noticed)

I'll have to update the link in my HTML version*. It also looks
like my copy is getting fairly out of date judging by a quick perusal
of the Q. #s listed in 'The GUI FAQ'.

I'll have to update mine 'real soon now'.

* I still want to retain the HTML version purely for the links/anchors.

[ BTW. Thank you for the good work. ]

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane

Back to top
Thomas Weidenfeller
Guest





PostPosted: Tue Nov 23, 2004 12:18 pm    Post subject: Re: newbie Reply with quote

Andrew Thompson wrote:
Quote:
On Tue, 23 Nov 2004 09:32:32 +0100, Thomas Weidenfeller wrote:


ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq


That's cool! (First time I'd noticed)

uu.nl was the only faq archive which I could find which had already
picked up the faq. rtfm.mit.edu didn't pick it up (rtfm.mit.edu seems
to be having some problems in general, and I didn't bother trying to
find someone responsible for it). And faqs.org just takes the faqs from
rtfm.mit.edu.

So, when looking for a comp.lang.java.gui FAQ one might still end up
with PvdLs stalled and abandoned programming FAQ from 1999. Some sites
also carry an old FAQ from Elliotte Rusty Harold from 1997. Both authors
don't seem to care any more about the newsgroups (interestingly, both
went on to write Java books, so that might explain their lack of
interest in their FAQs).

Quote:
* I still want to retain the HTML version purely for the links/anchors.

Either

http://www.cs.uu.nl/wais/html/na-dir/computer-lang/java/gui/faq.html

:-)

or see question Q1.7 of the FAQ Smile))

/Thomas


--
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq

Back to top
Andrew Thompson
Guest





PostPosted: Tue Nov 23, 2004 12:56 pm    Post subject: Re: newbie Reply with quote

On Tue, 23 Nov 2004 13:18:54 +0100, Thomas Weidenfeller wrote:

(GUI FAQ)
Quote:
http://www.cs.uu.nl/wais/html/na-dir/computer-lang/java/gui/faq.html

...and that's even better, but..

Quote:
or see question Q1.7 of the FAQ Smile))

...ahh. I was browsing the text version in a window (amongst many)
had not noticed that yet.

If only text2html could recognize the index for what it is,
and insert appropriate links and anchors (but I suppose that
is expecting too much of a text -> HTML converter).

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane

Back to top
Thomas Weidenfeller
Guest





PostPosted: Tue Nov 23, 2004 2:44 pm    Post subject: OT: FAQ format (was: Re: newbie) Reply with quote

Andrew Thompson wrote:
Quote:
If only text2html could recognize the index for what it is,
and insert appropriate links and anchors (but I suppose that
is expecting too much of a text -> HTML converter).

It is supposed to insert anchors. At least if it manages to match the
headers, which requires to provide the tool with a regexp for matching
headers.

But if anything else fails, a short awk script like the following should
be a good start to link the TOC to the actual paragraphs:

/__/ { t++ }

t == 1 {
if($1 != "") {
$1 = $1
print "<a href="#" $1"">" $0 "</a>"
next
}
}

t > 1 && /^[ ]*Q*[1-9][0-9]*(.[1-9][0-9]*)* / {
print "<a name="" $1 ""></a>" $0
next
}

{ print }


/Thomas


--
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq

Back to top
Andrew Thompson
Guest





PostPosted: Tue Nov 23, 2004 3:03 pm    Post subject: Re: OT: FAQ format Reply with quote

On Tue, 23 Nov 2004 15:44:58 +0100, Thomas Weidenfeller wrote:

Quote:
But if anything else fails, a short awk ..

(eeek)

Quote:
..script like the following should
be a good start to link the TOC to the actual paragraphs:

OK. Thanks for the tip. I'll mull that over and perhaps drop
in to to an awk group to find how it is applied.

If I can get something workable, will you apply it to the HTML
version of the GUI FAQ you provide? That would be easiest, as
then I could simply link from my FAQ.

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane

Back to top
Thomas Weidenfeller
Guest





PostPosted: Tue Nov 23, 2004 3:12 pm    Post subject: Re: OT: FAQ format Reply with quote

Andrew Thompson wrote:
Quote:
OK. Thanks for the tip. I'll mull that over and perhaps drop
in to to an awk group to find how it is applied.

Just run it with the file name as an argument Smile Ok, and be careful in
awk groups. These people expect that you have read the awk documentation
before asking Smile)

Quote:
If I can get something workable, will you apply it to the HTML
version of the GUI FAQ you provide?

I didn't create that HTML version. Someone at that particular archive
did set up an automatic text to HTML conversion. I still just provide
the text version, via posting it to newsgroups.

/Thomas

--
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.