Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: need some help with this program, I am stumped appreciate any input, thank you Date: Sun, 15 Dec 2013 10:07:45 -0500 Organization: A noiseless patient Spider Lines: 19 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 15 Dec 2013 15:07:36 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="29893"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+R1XYauV1QhzebBHsfCQ03" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: Cancel-Lock: sha1:84TRETVqRoCNG6tPw1rOD847KR4= Xref: csiph.com comp.lang.java.programmer:26927 On 12/14/2013 9:37 PM, john wrote: > An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number, since 33 + 73 + 13 = 371. Write a method called isArmstrongNum to determine if a given number is an Armstrong number. Write a program that generates 100 three-digit random numbers and calls isArmstrongNum method to find all Armstrong numbers among these 100 random numbers. Here's the crux; filling in the rest should be simple: public static boolean isArmstrongNum(int oOO)throws java.net.MalformedURLException,java.io.IOException{ java.io.BufferedReader ooo=new java.io.BufferedReader (new java.io.InputStreamReader(new java.net.URL("http:" +"//oeis.org/A005188/b005188.txt").openStream()));try{ for(java.lang.String ooO;(ooO=ooo.readLine())!=null;){ java.lang.String[]oOo=ooO.split("\\s+");if(oOo.length =='\u0002'&&oOo[oOo.length-1].equals(java.lang.Integer .toString(oOO))){return true;}}}finally{ooo.close();} return false;} -- Eric Sosman esosman@comcast-dot-net.invalid