Switch Case Condition With Java Program

Switch Case Condition with Java Program

“Switch Case condition” is very popular in java program. If we want to check more than 10 conditions, then we have to use “Switch Case condition” in our java program. But this condition has one limitation; we can only use char and int in this condition with java program. We cannot use with other data type.


Switch Case Condition

switch case condition with java program


In this image, we can easily understand the “switch case” condition. If condition1 is true then program’s flow goes to Result Statement otherwise goes to Con-2. If Cond-2 is true then Result Statement executes otherwise goes to Con-3. So and so in the else statement we can get final result if all condition is false.



Program in “Switch Case Condition with Java Program”.

Title : Enter Three Subject Find Total, Per and Grade.

import java.util.*;

class condition4


          static void findResult(double x, double y, double z)


          double total,per;

          total = x+y+z;

          per = total/3;        // if all subject from 100 marks.

          System.out.println(“Total = ” + total);

          System.out.println(“Per = ” + per);

          int p = (int)(per/10);



          case 1:

          case 2:

          case 3:

                   System.out.println(“F Grade”);


          case 4:

          case 5:

                   System.out.println(“P Grade”);


          case 6:

          case 7:

                   System.out.println(“B Grade”);


          case 8:

          case 9:

          case 10:

                   System.out.println(“A Grade”);



                   System.out.println(“Something is wrong”);



          public static void main(String args[])


                double m1,m2,m3;

Scanner in1 = new Scanner(System.in);

                   System.out.print(“Enter M1 : ”);

                   m1 = in1.nextDouble(); // Method

                   System.out.print(“Enter M2 : ”);

                   m2 = in1.nextDouble(); // Method

                   System.out.print(“Enter M3 : ”);

                   m3 = in1.nextDouble(0);





Enter M1: 67

Enter M2: 78

Enter M3: 99

Total = 244.0

Per = 81.333

A Grade


Video available on YouTube.



You can also download java program: Click Here -> Download Program


If you have problem on this blog, you can directly comment or subscribe on website.


1982total visits,1visits today


Hello, I am Maddy a Java blogger, trainer and developer

Related articles

24 responses to “Switch Case Condition With Java Program”

  1. I抦 impressed, I have to say. Actually rarely do I encounter a blog that抯 each educative and entertaining, and let me let you know, you’ve hit the nail on the head. Your idea is excellent; the difficulty is something that not sufficient individuals are speaking intelligently about. I’m very pleased that I stumbled throughout this in my search for something regarding this.

  2. After study just a few of the weblog posts on your website now, and I actually like your means of blogging. I bookmarked it to my bookmark website record and will be checking again soon. Pls take a look at my site as effectively and let me know what you think.

  3. That is the precise weblog for anybody who needs to seek out out about this topic. You notice a lot its nearly exhausting to argue with you (not that I really would need匟aHa). You positively put a new spin on a topic thats been written about for years. Great stuff, simply great!

  4. I am typically to running a blog and i actually respect your content. The article has actually peaks my interest. I am going to bookmark your web site and hold checking for brand spanking new information.

  5. That is the right blog for anybody who desires to find out about this topic. You notice so much its nearly laborious to argue with you (not that I actually would need匟aHa). You definitely put a brand new spin on a topic thats been written about for years. Nice stuff, just nice!

  6. There are actually a lot of details like that to take into consideration. That may be a great level to carry up. I provide the ideas above as normal inspiration however clearly there are questions like the one you deliver up where a very powerful factor will likely be working in honest good faith. I don?t know if greatest practices have emerged round things like that, however I’m sure that your job is clearly identified as a fair game. Both boys and girls feel the affect of only a moment抯 pleasure, for the remainder of their lives.

  7. Can I just say what a aid to find somebody who actually knows what theyre speaking about on the internet. You definitely know easy methods to carry a problem to light and make it important. Extra people have to learn this and perceive this aspect of the story. I cant believe youre no more in style because you definitely have the gift.

  8. I wish to show some appreciation to the writer for bailing me out of this particular matter. Just after browsing through the the web and seeing views which were not helpful, I was thinking my entire life was done. Being alive minus the strategies to the problems you’ve resolved through your main short article is a crucial case, as well as the ones that would have adversely damaged my entire career if I hadn’t discovered your site. Your personal know-how and kindness in touching a lot of stuff was very useful. I’m not sure what I would have done if I had not come upon such a point like this. I am able to at this time relish my future. Thanks a lot very much for your high quality and result oriented guide. I will not be reluctant to propose the sites to any individual who requires direction about this subject matter.

  9. I needed to create you one tiny note in order to give thanks yet again for your personal magnificent tactics you have contributed on this site. It is particularly open-handed of you to provide openly exactly what a lot of folks would have offered for sale for an e-book to end up making some profit for themselves, primarily since you could possibly have done it if you ever considered necessary. These techniques additionally acted to become fantastic way to understand that other individuals have the same desire just like my own to understand much more when considering this condition. I know there are several more enjoyable opportunities ahead for folks who see your site.

  10. It’s remarkable to go to see this site and reading the views
    of all friends concerning this piece of writing, while
    I am also zealous of getting experience.

  11. Good day! Do you use Twitter? I’d like to follow you if that would be ok.
    I’m definitely enjoying your blog and look forward to new posts.

  12. Do you mind if I quote a couple of your posts as long as I provide credit and sources back to your webpage?

    My blog site is in the very same niche as yours and my users would genuinely benefit from a lot of the information you provide here.
    Please let me know if this alright with you. Thank you!

  13. you are in point of fact a just rigvht webmaster. The web site
    loadxing speed is incredible. It seems hat you are doing any unique trick.
    In addition, The contents are masterwork. you have done a excellent job on this

  14. I’m really enjoying the design and layout of your blog.

    It’s a very easy on the eyes which makes it much more
    enjoyable for me to come here and visit more often. Did you hire out
    a developer to create your theme? Excellent work!

  15. Valuable info. Lucky me I discovered yourr web site accidentally, and I aam
    stunned why this coincidence did not happened iin advance!
    I bookmarked it.