Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Knute Johnson Newsgroups: comp.lang.java.programmer Subject: Re: Help writing a program using a switch statement Date: Fri, 10 Oct 2014 20:27:12 -0700 Organization: A noiseless patient Spider Lines: 48 Message-ID: References: <8dcbb682-a1c4-4e43-b506-093de204ae87@googlegroups.com> <54388fd2$0$292$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sat, 11 Oct 2014 03:27:10 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="aba33539224e5c782fe0c4053f7756fd"; logging-data="12385"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+DKGwJxB//BXXuT6riEx4m" User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 In-Reply-To: <54388fd2$0$292$14726298@news.sunsite.dk> Cancel-Lock: sha1:qfCJgrXReUdX9RT+qsTCBTFntSc= Xref: csiph.com comp.lang.java.programmer:30074 On 10/10/2014 19:02, Arne Vajhøj wrote: > On 10/5/2014 8:18 PM, Knute Johnson wrote: >> On 10/5/2014 15:40, Abraar Ahmed wrote: >>> Write a program using switch statement to allow users to choose an >>> item of a menu. For example, the menu looks like the following. > >>> switch (1) { >>> case value: 1 >>> System.out.println ("Open is selected"); >>> break; >>> case value: 2 >>> System.out.println ("Close is selected"); >>> break; >>> case value: 3 >>> System.out.println ("Save is selected") >>> break; >>> System.out.println ("Exit is selected") >>> default: >>> values_not_caught_above; >>> >>> } > >> Since this is homework, you need to look at the Java Language >> Specification, chapter 14.11 Switch Statement. Everything you need to >> know is there. >> >> http://docs.oracle.com/javase/specs/jls/se8/html/index.html > > JLS is good for many things, but learning basic Java syntax is not > one if them. > > The Java tutorial would be a lot easier to learn from. > > http://docs.oracle.com/javase/tutorial/java/index.html > > http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html > > Arne > > > There are some good examples in the JLS for the switch statement though. That's why I told him to look there. -- Knute Johnson