Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: About java program. Date: Tue, 18 Jun 2013 04:06:13 -0400 Organization: A noiseless patient Spider Lines: 31 Message-ID: References: <324f929f-772e-4004-81e1-6b454cdae794@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 18 Jun 2013 07:59:52 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="6b9e92482af47766954d85fb77d372f5"; logging-data="24504"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18bph2JW55XWBAc73mVILjH9sugBC7e1KE=" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130529 Icedove/17.0.5 In-Reply-To: <324f929f-772e-4004-81e1-6b454cdae794@googlegroups.com> Cancel-Lock: sha1:Uo6vqoJ9BpCrrKvv22VwVHTOTWg= Xref: csiph.com comp.lang.java.programmer:24450 On 06/15/2013 04:38 PM, rajbhaumik@gmail.com wrote: > import acm.program.*; > public class askYesNoQuestion extends ConsoleProgram { > public void run(){ > String str=readLine("Would you like instructions"); > println(askYesNoquestion(str)); > } > 7. private boolean askYesNoquestion (String str){ > if(str.equals("yes"))return true; > if(str.equals("no")) return false; > } > > } > the false is that , the program cannot be executed, because no 7 said , this method must return a type of boolean. > import acm.program.ConsoleProgram; @SuppressWarnings("serial") public class AskYesNoQuestion extends ConsoleProgram { public void run() { boolean answer = readBoolean( "Have you read the manual?", "Yes", "No"); if(answer) println("Yes, I will read the manual."); else println("Yes, I will read the manual.\n" +""); } }