Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: Double always returning 0.0 Date: Mon, 18 Apr 2011 17:43:38 -0700 Organization: A noiseless patient Spider Lines: 20 Message-ID: References: <201104182005433244-jasonsavlov@mecom> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 19 Apr 2011 00:43:41 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="XMIQHpqNaML83cYm5DYg+A"; logging-data="26169"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19RyfGKvWPMclk+KZ/b9tiyiLI95jaXqkI=" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: <201104182005433244-jasonsavlov@mecom> Cancel-Lock: sha1:rPLQ9Yz0GDear9hCMp2LL8AlKdQ= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3125 On 4/18/2011 5:05 PM, Jason S wrote: > I'm trying to figure out why I can't seem to get my program to return > the correct value here. It always returns 0.0 even though I (think) that > everything is declared/cast correctly... > > Code located at http://web.cs.sunyit.edu/~savlovj/CS249/pg472_8 > > My guess would be you're getting the wrong values from the scanner into the wrong variables. The places where you have two calls of nextLine() in a row, throwing away both values, seems especially suspect. Suggestion 1. Print out the value of each variable after you read it in with s_scan and show us the result. Suggestion 2. Use next(), not nextLine(). Set the delimiter to "(\r\n)|(\n)" for newlines.