Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: switch problem

  1. #1
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default switch problem

    [









    package sara;
    import java.util.Scanner;
    public class Sara {


    public static void main(String[] args) {
    System.out.println( "Enter month " );
    int month;
    Scanner in=new Scanner(System.in);
    month=in.nextInt();
    switch(month)
    {
    Case 1: System.out.println("january"); break; // error
    Case 2: System.out.println("feburary"); break; // error
    Case 3: System.out.println("march"); break; //error


    default:System.out.println("invalid month"); break;

    }
    }

    }







    ]/[




    Enter month
    jan
    Exception in thread "main" java.util.InputMismatchException
    at java.util.Scanner.throwFor(Scanner.java:909)
    at java.util.Scanner.throwFor(Scanner.java:909)
    at java.util.Scanner.next(Scanner.java:1530)
    at java.util.Scanner.nextInt(Scanner.java:2160)
    at java.util.Scanner.nextInt(Scanner.java:2119)
    at sara.Sara.main(Sara.java:11)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 8 seconds)







    ]

    --- Update ---

    error in switch getting

    --- Update ---

    eeroin switch help plz frnds output is not coming properly


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: switch problem

    You have been asked in the past to wrap your code in the code tags, as well as read Announcements - What's Wrong With My Code? Continue to ignore this advice is not doing you favors in getting help.

    I would also highly recommend writing in proper English. This is a technical forum, and words like 'plz' and 'frnds' makes your posts hard to read, and in same cases with your previous posts virtually impossible to understand.

Similar Threads

  1. Switch case problem
    By pavani in forum Loops & Control Statements
    Replies: 4
    Last Post: August 11th, 2013, 09:34 PM
  2. Switch problem
    By SilentNite17 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 6th, 2013, 06:22 AM
  3. Switch Case Problem help
    By Kikiam in forum What's Wrong With My Code?
    Replies: 13
    Last Post: March 18th, 2012, 06:11 PM
  4. Credit Card Problem (While and Switch will be used)
    By odun in forum Object Oriented Programming
    Replies: 3
    Last Post: March 29th, 2011, 12:54 AM
  5. switch and math problem issues
    By emartino in forum Java Theory & Questions
    Replies: 1
    Last Post: January 19th, 2010, 05:34 PM