wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Switch help? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Switch help?" Watch "Switch help?" New topic
Author

Switch help?

xiao sean
Ranch Hand

Joined: Aug 20, 2007
Posts: 44
hi guys.
i need some help here as i'm unable to debug this program. i just pick up basic java programming.

my output always will become default, which i have no idea where went wrong, appricated help from you guys..
thanks
----------------
class Displayday
{
public static void main (String[]args)
{

int day = Integer.parseInt (args[0]);

switch ( day )
{
case '1': System.out.println("today is monday"); break;
case '2': System.out.println("today is tuesday"); break;
case '3': System.out.println("today is wednesday"); break;
case '4': System.out.println("today is thursday"); break;
case '5': System.out.println("today is friday"); break;
case '6': System.out.println("today is saturday"); break;
case '7': System.out.println("today is sunday"); break;
default : System.out.println(" Sorry, Wrong i/p. Try again");
}
}
}

------------
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

"sayno,"

Welcome to JavaRanch! Please check your private messages by clicking on the "My Profile" link near the top of the page.

Your cases have the ints in single quotes, which make them chars. Remove the single quotes, and it should work.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
xiao sean
Ranch Hand

Joined: Aug 20, 2007
Posts: 44
hi , thanks for yr info.

but i have a doubt. what is a single quote?
xiao sean
Ranch Hand

Joined: Aug 20, 2007
Posts: 44
ohh i get what you meant.. thanks for the help..
really appricated..
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14279
    
  21

"sean", your name is still not according to the JavaRanch policy. Please take a moment to read the policy carefully. Your name must consist of a first name, space, and a second name. Not just a first name.

Please change your display name again so that it conforms to the policy. You can change your name by editing your profile.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Switch help?