944,084 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2463
  • Java RSS
Sep 30th, 2007
0

New to java I need help with switch case error

Expand Post »
I am new to Java and can not figure out why I am getting this error for swithc case.
Attached Files
File Type: java ConvertTemp05.java (2.3 KB, 18 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
champagne is offline Offline
2 posts
since Sep 2007
Sep 30th, 2007
0

Re: New to java I need help with switch case error

1) Please post your code here.
2) Make sure you indent your code properly
3) Use [code][/code] tags
4) Post what error messages you get.
Last edited by iamthwee; Sep 30th, 2007 at 7:30 am.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Sep 30th, 2007
0

Re: New to java I need help with switch case error

Not sure what problem you are facing... but one obvious thing i spotted is that you are having a statement after the break; You might have got 'Unreachable code' error. If that's not your issue, could you elaborate on your problem? Also, could you please correct indentation?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
venkatev is offline Offline
1 posts
since Sep 2007
Sep 30th, 2007
0

Re: New to java I need help with switch case error

You have two curly bracklets on start of switch statement and only one on closing
Java Syntax (Toggle Plain Text)
  1. switch (sCode){
  2. {
  3. case 'c':
  4. case 'C':
so delete one.
However once this done there is another 13 error messages which you need to sort. GL
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,659 posts
since Dec 2004
Sep 30th, 2007
0

Re: New to java I need help with switch case error

Click to Expand / Collapse  Quote originally posted by champagne ...
I am new to Java and can not figure out why I am getting this error for swithc case.
I did correct the errors but I can not get the input message for Fahrenheit to show ConvertTemp05 in the heading box. and the 'c' to show. It only shows c. I have attached the correct code

Thanks a bunch
Attached Files
File Type: java ConvertTemp05.java (2.3 KB, 14 views)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
champagne is offline Offline
2 posts
since Sep 2007
Oct 2nd, 2007
0

Re: New to java I need help with switch case error

The code you have given have following problems:
1. There is no java object type called "character". Might be you wanted "Character".
2. You have not defined what is "input" variable on line 28.
3. You have not defined "temp", "cel", "df" before you used them. You can not initiate them whenever you want. (Happened for "df")
4. This whole line has formatting error:
Java Syntax (Toggle Plain Text)
  1. JOptionPane.showMessageDialog(null, (cel + " degrees in Celsius is " + df.format (f) + " degrees in Fahrenheit." "ConvertTemp05");
5. What is "fht"?????????????
Please fix these problems first, the program should work. (I am wondering how did you get any kind of output.. the code should not compile even)... Good luck..
Reputation Points: 46
Solved Threads: 11
Junior Poster
orko is offline Offline
164 posts
since Apr 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: simple call
Next Thread in Java Forum Timeline: Interface Expected Error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC