Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #30076

Re: Help writing a program using a switch statement

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 Knute Johnson <eternal@knutejohnson.com>
Newsgroups comp.lang.java.programmer
Subject Re: Help writing a program using a switch statement
Date Sat, 11 Oct 2014 07:59:49 -0700
Organization A noiseless patient Spider
Lines 60
Message-ID <m1bgl2$m76$1@dont-email.me> (permalink)
References <8dcbb682-a1c4-4e43-b506-093de204ae87@googlegroups.com> <m0sn3e$33q$1@dont-email.me> <54388fd2$0$292$14726298@news.sunsite.dk> <m1a82e$c31$1@dont-email.me> <543933f5$0$301$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 14:59:46 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="aba33539224e5c782fe0c4053f7756fd"; logging-data="22758"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dY/wPPoyR2vdVklEISHUU"
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1
In-Reply-To <543933f5$0$301$14726298@news.sunsite.dk>
Cancel-Lock sha1:UNa6R7ZGbNlDjsShyly686YzfaU=
Xref csiph.com comp.lang.java.programmer:30076

Show key headers only | View raw


On 10/11/2014 06:43, Arne Vajhøj wrote:
> On 10/10/2014 11:27 PM, Knute Johnson wrote:
>> 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
>>
>> There are some good examples in the JLS for the switch statement though.
>
> It has 3 examples:
> * some code that works in C/C++ but does not work in Java
> * some code showing fall through
> * some normal code
>
> Compare that to the tutorial that has 5 examples:
> * some normal code
> * some code showing how it would look like using if else if
> * some code showing fall through
> * some code showing multi labels
> * some code showing switch on strings
>
> Arne

OK I concede, you should have answered him not me.

-- 

Knute Johnson

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Help writing a program using a switch statement Abraar Ahmed <abraar93@gmail.com> - 2014-10-05 15:40 -0700
  Re: Help writing a program using a switch statement Knute Johnson <eternal@knutejohnson.com> - 2014-10-05 17:18 -0700
    Re: Help writing a program using a switch statement Arne Vajhøj <arne@vajhoej.dk> - 2014-10-10 22:02 -0400
      Re: Help writing a program using a switch statement Knute Johnson <eternal@knutejohnson.com> - 2014-10-10 20:27 -0700
        Re: Help writing a program using a switch statement Arne Vajhøj <arne@vajhoej.dk> - 2014-10-11 09:43 -0400
          Re: Help writing a program using a switch statement Knute Johnson <eternal@knutejohnson.com> - 2014-10-11 07:59 -0700
  Re: Help writing a program using a switch statement rossum <rossum48@coldmail.com> - 2014-10-06 09:38 +0100
  Re: Help writing a program using a switch statement Roedy Green <see_website@mindprod.com.invalid> - 2014-10-06 20:25 -0700
  Re: Help writing a program using a switch statement Henry Reardon <No_contact@example.com> - 2014-10-10 16:01 +0000

csiph-web