Hand Cricket Project In Java (BlueJ)

By | December 13, 2015

Odd-Even Hand Cricket Game

In this post, I will be sharing with you an awesome “Hand Cricket Game” project created by me in Java Programming Language. I created this project years ago during my school days. This is just one of the many Java projects that I created. I used BlueJ to compile and run these Java programs and I recommend you to do the same.

Here is a short explanation by me about Hand Cricket:

Hand Cricket is a very famous game among the school kids in India and similar countries. Traditionally, there are two players who will be playing the game, and after performing a ‘toss’, one chooses to bat and the other has to bowl. Both the players will (through hand gestures called ‘throws’) simultaneously signify a number between 1 to 10. If both the players point out the same number, the player who is batting gets ‘out’, else, this is repeated and whatever number the batting player (batsman) keeps throwing are added and that becomes his/her score.

After the batsman gets out, the bowling player (bowler) becomes the batting player and vice-versa. Now, the process is repeated again and finally, if the original bowler scores more than the original batsman, he wins. If they both score the same runs and both get ‘out’, then it is declared as a tie. If the original batsman scores more than the original bowler, he wins. Simple as that. I hope you understood. :) :) :)

Below, I have uploaded a video of some Indian guys having a lot of fun playing “Odd-Even Team Hand Cricket Game”. If you have never heard of Hand Cricket in your life, you should definitely watch this video! It will surely cheer you up. :D :D :D


 


Now, enough about Hand Cricket and let’s talk about my Hand Cricket Project in Java Language.

Below are some of the purposes for which I have posted this project/assignment on this blog:

  • To provide for class X (10th standard) or class XII (12th standard) computer applications project in Java for ICSE, CBSE, HSC etc. students (especially in India)
  • To provide for any other class’ or standard’s java project required by school or college students of any board (especially in India)
  • To give an idea to the people about how creative one can be in Java programming
  • To provide an insight as to how the beautiful game called “Hand Cricket” can be implemented into Java

I am allowing you guys to use/download this project created by me for completely free! This is a “free royalty free project“. Yeah, that’s right fellas! It means that there is no need to credit me anywhere. Take all the credit for making this program in Java all by yourself if that pleases you. :mrgreen: :mrgreen: :mrgreen: Here you go!

 


Input Code:

// Program written by The Adarsh Mehta
// www.theadarshmehta.in

import java.io.*;

public class Playing_Hand_Cricket_Against_Computer

{

    public static void main(String args[])throws IOException
    
    {
        
        InputStreamReader isr=new InputStreamReader(System.in);
        BufferedReader br=new BufferedReader(isr);
        
        String name; // to accept the player's name;
        int aa; // converting the random real number generated by 'rr' into a random whole number run for the computer;
        int ii; // used in for loops;
        int bb; // to accept the player's number;
        double rr; // to generate a random real number;
        int cheat; // to end the game if wrong input is entered; to keep a check whilst the game is running as to whether the game has ended or not;
        int score1; // to store the latest runs scored by the player;
        int score2; // to store the latest runs scored by the computer;
        int c; // used in for loops to create a specific design;
        int choice; // used to decide whether the game needs to be ended or restarted;
        int infinity=1; // used to keep the game running until the player decides to end the game;
        
        /* After referring to all the comments mentioned above,
         * you must be able to understand the working of this program as it is very easy.
         * If you find it complicated,
         * feel free to visit www.theadarshmehta.in
         * and contact The Adarsh Mehta.
         * Have fun!
         */
        
        while(infinity>0)
        {
            
            name=" ";
            aa=0;
            ii=0;
            bb=0;
            rr=0;
            cheat=0;
            score1=0;
            score2=0;
            c=0;
            choice=0;
            infinity=1;
            
            System.out.println("=======================");
            System.out.println("| WELCOME TO THE GAME |");
            System.out.println("=======================");
            System.out.println("");
            System.out.print("Enter Your Name: ");
            name=br.readLine();
            
                for(c=0;c<=2;c++)
                {
                    System.out.println("====================================");
                }
                
                System.out.println("Hello "+name+",");
                System.out.println(".");
                System.out.println("WELCOME TO THE CRICKET-MANIA");
                System.out.println(".");
                System.out.println("Instructions:");
                System.out.println(".");
                System.out.println("This Game Is Similar To The Hand-Cricket Game Played By Kids.");
                System.out.println(".");
                System.out.println("There Is No Limit On The Number Of Balls.");
                System.out.println(".");
                System.out.println("You Will First Bat. Enter Any Number From 1 To 10.");
                System.out.println(".");
                System.out.println("Enter The Numbers Carefully Without Making Any Mistake.");
                System.out.println(".");
                System.out.println("If The Number Entered By The Computer Is Same As The Number Entered By You,");
                System.out.println("You Will Be Declared As Out.");
                System.out.println(".");
                System.out.println("Your Final Score Will Be The Sum Of The Numbers You Entered Before Getting Out.");
                System.out.println(".");
                System.out.println("After Getting Out, You Will Have To Bowl.");
                System.out.println(".");
                System.out.println("Try To Enter A Number Similar To The Number Entered By The Computer.");
                System.out.println(".");
                System.out.println("If The Sum Of Numbers Entered By The Computer Becomes More Than Your Score, It Will Win.");
                System.out.println(".");
                System.out.println("But If You Enter A Number Same As The Number Entered By The Computer, You Can Win!");
                System.out.println(".");
                
                for(c=0;c<=2;c++)
                {
                    System.out.println("====================================");
                }
                
                System.out.println("YOU ARE BATTING:");
                
                for(c=0;c<=2;c++) { System.out.println("===================================="); } for(ii=1;ii>0;ii++)
                {
                    System.out.println("");
                    System.out.print("Enter Your Number: ");
                    bb=Integer.parseInt(br.readLine());
                    rr=((Math.random())*10);
                    rr=rr+1;
                    aa=(int)(rr);
                    System.out.println("");
                    System.out.println("Computer's Number: "+aa);
                    System.out.println("");
                    System.out.println("**********");
                    System.out.println("");

                    if(bb==aa)
                    {
                        System.out.println(" ");
                        System.out.println("HOWZATTT!!!!!!");
                        System.out.println(" ");
                        System.out.println("################");
                        System.out.println("################");
                        System.out.println("YOUR FINAL SCORE = "+score1);
                        System.out.println("################");
                        System.out.println("################");
                        System.out.println(" ");
                        break;
                    }
                    
                    else if(bb>0&&bb<=10) { score1=score1+bb; } else if(bb>10||bb<=0)
                    {
                        for(c=0;c<=2;c++)
                        {
                            System.out.println("====================================");
                        }
                        System.out.println("You have either tried to cheat or entered a wrong input. Game Over!");
                        cheat++;
                        break;
                    }

                    System.out.println("Your Current Score Is "+score1);
                    System.out.println("");
                    System.out.println("**********");
                }
                
                for(c=0;c<=2;c++) { if(cheat>0)
                    {
                        break;
                    }
                    System.out.println("====================================");
                }
                
                for(c=0;c<1;c++) { if(cheat>0)
                    {
                        break;
                    }
                    System.out.println("YOU ARE BOWLING:");
                }
                
                for(c=0;c<=2;c++) { if(cheat>0)
                    {
                        break;
                    }   
                    System.out.println("====================================");
                }
                
                for(ii=1;ii>0;ii++)
                {
                    if(cheat>0)
                    {
                        break;
                    }
                    
                    System.out.println("");
                    System.out.print("Enter Your Number: ");
                    bb=Integer.parseInt(br.readLine());
                    rr=((Math.random())*10);
                    rr=rr+1;
                    aa=(int)(rr);
                    System.out.println("");
                    System.out.println("Computer's Number: "+aa);
                    System.out.println("");
                    System.out.println("**********");
                    System.out.println("");
                    
                    if(aa==bb)
                    {
                        System.out.println(" ");
                        System.out.println("COMPUTER IS OUTT!!!!");
                        System.out.println(" ");
                        System.out.println("################");
                        System.out.println("################");
                        System.out.println("COMPUTER'S FINAL SCORE = "+score2);
                        System.out.println("################");
                        System.out.println("################");
                        System.out.println(" ");
                        break;
                    }
                    
                    else if(bb>0&&bb<=10) { score2=score2+aa; } else if(bb>10||bb<=0)
                    {
                        for(c=0;c<=2;c++) { System.out.println("===================================="); } System.out.println("You have either tried to cheat or entered a wrong input. Game Over!"); cheat++; break; } if(score2>score1)
                    {
                        System.out.println(" ");
                        System.out.println("THE COMPUTER HAS SCORED MORE THAN YOUU!!!");
                        System.out.println(" ");
                        System.out.println("################");
                        System.out.println("################");
                        System.out.println("COMPUTER'S FINAL SCORE = "+score2);
                        System.out.println("################");
                        System.out.println("################");
                        System.out.println(" ");
                        break;
                    }
                    
                    System.out.println("Computer's Current Score Is "+score2);
                    System.out.println("");
                    System.out.println("**********");
                }
                
                for(c=0;c<=2;c++) { if(cheat>0)
                    {
                        break;
                    }
                    
                    System.out.println("====================================");
                }
                
                for(ii=0;ii<1;ii++) { if(cheat>0)
                    {
                        break;
                    }
                    
                    System.out.println(" ");
                    System.out.println("################");
                    System.out.println("################");
                    System.out.println("YOUR FINAL SCORE = "+score1);
                    System.out.println("COMPUTER'S FINAL SCORE = "+score2);
                    System.out.println("################");
                    System.out.println("################");
                    System.out.println(" ");

                    if((score1)>(score2))
                    {
                        System.out.println("Congratulations "+name+"!! You Have Defeated The Almighty, Computer!!");
                    }
                    
                    else if((score1)<(score2))
                    {
                        System.out.println("Sorry "+name+", But The Computer Has Defeated You..!");
                    }
                    
                    else
                    {
                        System.out.println("It's a Tie..! :(");
                    }
                    
                }
                
                for(c=0;c<=2;c++)
                {
                    System.out.println("====================================");
                }
            
            System.out.println("");
            System.out.println("Enter 1 To Play This Game Again.");
            System.out.println("");
            System.out.println("Enter 0 Or Any Other Number To Quit.");
            choice=Integer.parseInt(br.readLine());
            System.out.println("");
            
            if(choice==1)
            {
                System.out.print('\f');
            }
            
            else
            {
                System.out.print('\f');
                System.out.println("Good Bye!");
                break;
            }
            
        }
    }
}

// Program written by The Adarsh Mehta
// www.theadarshmehta.in

 

Output:

=======================
| WELCOME TO THE GAME |
=======================

Enter Your Name: Adarsh
====================================
====================================
====================================
Hello Adarsh,
.
WELCOME TO THE CRICKET-MANIA
.
Instructions:
.
This Game Is Similar To The Hand-Cricket Game Played By Kids.
.
There Is No Limit On The Number Of Balls.
.
You Will First Bat. Enter Any Number From 1 To 10.
.
Enter The Numbers Carefully Without Making Any Mistake.
.
If The Number Entered By The Computer Is Same As The Number Entered By You,
You Will Be Declared As Out.
.
Your Final Score Will Be The Sum Of The Numbers You Entered Before Getting Out.
.
After Getting Out, You Will Have To Bowl.
.
Try To Enter A Number Similar To The Number Entered By The Computer.
.
If The Sum Of Numbers Entered By The Computer Becomes More Than Your Score, It Will Win.
.
But If You Enter A Number Same As The Number Entered By The Computer, You Can Win!
.
====================================
====================================
====================================
YOU ARE BATTING:
====================================
====================================
====================================

Enter Your Number: 5

Computer’s Number: 9

**********

Your Current Score Is 5

**********

Enter Your Number: 5

Computer’s Number: 10

**********

Your Current Score Is 10

**********

Enter Your Number: 5

Computer’s Number: 7

**********

Your Current Score Is 15

**********

Enter Your Number: 5

Computer’s Number: 5

**********
HOWZATTT!!!!!!

################
################
YOUR FINAL SCORE = 15
################
################

====================================
====================================
====================================
YOU ARE BOWLING:
====================================
====================================
====================================

Enter Your Number: 5

Computer’s Number: 9

**********

Computer’s Current Score Is 9

**********

Enter Your Number: 10

Computer’s Number: 6

**********

Computer’s Current Score Is 15

**********

Enter Your Number: 5

Computer’s Number: 8

**********
THE COMPUTER HAS SCORED MORE THAN YOUU!!!

################
################
COMPUTER’S FINAL SCORE = 23
################
################

====================================
====================================
====================================

################
################
YOUR FINAL SCORE = 15
COMPUTER’S FINAL SCORE = 23
################
################

Sorry Adarsh, But The Computer Has Defeated You..!
====================================
====================================
====================================

Enter 1 To Play This Game Again.

Enter 0 Or Any Other Number To Quit.

0

Good Bye!

 


Wrapping Up

Copy and paste this program code into BlueJ or any other similar software, compile it, run it and test it out! If you play this game smartly, and you will most likely win majority of the times because we are obviously smarter than these puny computers.

Comment below if you face any problems or errors while running this piece of code and I’ll be more than happy to solve your queries. I normally ask you all to share my posts with your friends but in this case, I will not because you wouldn’t do it anyways, would you? It is too valuable to be shared with people around you as it will then make it clear that you did not write it. :lol: :lol: :lol:

Thank you.

LINK TO THIS POST:

<a href="https://www.theadarshmehta.in/blog/hand-cricket-project-in-java/2015/12">Hand Cricket Project In Java (BlueJ)</a>

Spread the love

175 thoughts on “Hand Cricket Project In Java (BlueJ)

  1. Tejan Gandhi

    Awesome, I was learning Java programming and I made the same project as well (Before looking into your code). Was just hanging around in the web to see other people’s codes. It’s really nice and creative. There’s a loophole in your program though! If I enter any number more than 10, I’ll never get out, and hence I can score as many runs as I can. Also, feel free to contact me if you want to collaborate and make something more creative and usable (like playing over networks or adding graphics or other stuff in this). Also, I’ve seen your details and seems like you’re 3 years elder than me, so perhaps you might’ve graduated. Do you mind me asking what is your major? If it’s computer science or similar, it would be great, because I’m pursuing Computer science as well! Hope to collaborate with you!

    Reply
  2. b sutheekshna

    hi
    can i get the flowchart and algorithm on hand cricket project in java using source code

    Reply
  3. dhanush

    what is the function of /f in the last and the purpose of cheat in the last can u tell me

    Reply
  4. Prajwal

    Bro u have more games programs with u. I need to do 3 games and I’ve done 1 now

    Reply
  5. JINAM SANCHETI

    SORRY TO SAY ! BUT MY HAND CRICKET PROGRAM IS MORE EFFICIENT THAN YOURS .

    Reply
  6. SHANU

    HI ADARSH , I NEED A HELP I WANT TO MAKE MOBILE SHOWROOM PROGRAM BUT I CANNOT ABLE TO DO IT PLEASE CAN YOU MAKE A SHOT PROGRAM FOR PLEASE

    Reply
  7. Ziyad Khan

    Bro please explain me how to generate a whole number in bluej……and yes your program is awesome

    Reply
    1. JINAM SANCHETI

      import java.util.*;
      {
      public static void main(int n)
      {
      for(int i=0;i<=n;i++)
      {
      System.out.println(i);
      }
      }
      }

      Reply
  8. Nasrullah

    hello adarsh dude, i have atlast scored a century on the hand cricket thanks for this awesome game man.please create more interactive games like this

    Reply
  9. Nasrullah

    please make more programs like this i am also looking forward for some graphic interface games,and thank you for this program

    Reply
  10. Manjula

    Your program is awesome.
    Can you please mention the purpose of your methods and classes in your program.

    Reply
  11. Sona

    Thank you it helped me a lot the program is awsome
    thanks a lot again

    Reply
  12. Infinity Craze

    Awesome programming skills! Thanks for taking time to publish it online for us!

    And even more thanks for a simple, non-complicated version of this.

    Reply
  13. Yash

    hi Adarsh…
    I went through the programe it is quite interesting and u can make few changes in it if u want….i.e, giving team option and u can also use switch case or scanner class to make it less complicated…
    doing a programe so big there will be some errors can u tell me how many times did u check for errors…Which college r u
    GOOD WORK

    Reply
  14. ayushi

    Can you please tell the variable description of this program . Do you have any other program of less than of 100 lines , because I wrote a program which has a lot of errors and I can’t fix it .

    Reply
  15. SRIJIT CHAKRABORTY

    hi Adarsh you can make this program better by making a toss system where you can choose to bat or to bowl

    Reply
  16. AK

    what is the use of /f in the last…………………its urgent pls tell it fast

    Reply
  17. Aneesh

    Its awesome game I am really enjoying it actually we have got a project on this and after doing this I have got full marks thanks bro

    Reply
      1. Sankalp Bansal

        Hey Adarsh,

        You’re Quite Brilliant. I Love Java Programming. And The Best Way To Get Guidance In It Is From You. Your Cricket Game Is Awesome. Just I wanna Ask You That In The Program, The First Loop You’ve Created(while loop), Why haven’t you’v closed It With Braces ??

        One More Thing Can You Tell Me Some Java Typical Programs For Class IX That I Can Practice.

        Thank You,

        Reply
  18. Soham Shah

    Hi. I’m in 10th class. Not bragging but I wrote the same program in 91 lines without using buffer or input string reader. I don’t even know what they are.
    Cheers!!

    Reply
    1. Adarsh Mehta Post author

      Soham, that IS bragging, :mrgreen: hahaha, but it is completely acceptable. ;) It’s great you were able to write the same game in like 91 lines without using buffer or input string reader! I am guessing you used ‘scanner’…

      And please do know that while writing this program, my aim was not to make it as small as possible. Otherwise, I could have made it very very less in length, as a very good portion of my program is filled with designs and explanations and blank lines and other fancy stuff which just makes my program look neat and tidy, easily understandable and lengthy. While submitting projects, these factors are also important and so only reducing the length of the program as much as possible is not of utmost importance, at least not at 10th Standard Level.

      I would really like it if you share your program code with us. :)

      Thank you.

      Reply
      1. Soham Shah

        Haha, yes I did use Scanner. And I got your point. I was hesitant to give my code because this is my boards project but then, your’s is quite the same. So here it is –

        https://pastebin.com/yssD5gUx

        Reply
        1. Adarsh Mehta Post author

          I have checked and it is fine. Good work bro. :) And I have also replied to you by email about the issue you were facing.

          Thank you.

          Reply
  19. Sarthak

    Sir , can u please upload a switch case program of 300 lines??
    I would be highly obliged if u do so.
    With regards,
    Sarthak Sharma.

    Reply
  20. Honey

    Hi sir I am honey. I need your phone number to talk with you. Can I get please

    Reply
  21. Siddhi

    Hi Aadarsh,
    You hv done a Great work in making this project.
    I am in 10th icse and have a project topic regarding the online fantasy cricket game( just like Dream 11) but I do not know where to start from.
    Can U plz give some ideas??

    Reply
  22. Patil

    My JDK is 7 and when I paste the program and tried to run in BlueJ then asks for input

    Reply
      1. Nameer

        Sir your program is very good but I have got a project of making a program of 40 pages on any of the topics
        Ipl
        online ticket
        dominos
        pizza hut
        But I’m not getting that how can I make a program on these programs

        Reply
        1. Adarsh Mehta Post author

          Hello, Nameer.

          First of all, gracias for giving a compliment on my program. Means a lot to me. :)

          All the four topics that you have mentioned are great choices. You can choose any one of them and you will be just fine! :D Me, personally, would go for either Dominos or Online Ticket.

          Just sit and plan all the options and details that will come into the program, and then prepare a nice flow-chart to demonstrate it neatly on a piece of paper. Keep on adding more and more options and details at each level so that when you convert your flow-chart into a real program, your program code is lengthy enough to fill the 40 pages… :D

          If you face any difficulties while writing the program code or have any other doubts or questions, feel free to comment. ;)

          Thank you.

          Reply
          1. Gautam jajodia

            Hey adarsh in bluej this program is not showing void main() option. What to do?

  23. Mitul Agrawal

    Hey give me you email (or just email me) and I’ll send you my programs and you tell how they are. I am in 10 th std ICSE, can you recommend me any good program I should make for my project.

    Reply
    1. Adarsh Mehta Post author

      Sorry for replying so late, Mitul. Your comment had just escaped my eyes. :-D

      My email id is theadarshmehta@gmail.com. Feel free to send me anything you want. I am not as free as I’d like to be right now, but I’ll try my best to reply within a few days after checking out your program.

      And regarding choosing a nice topic for your project, please go through the other comments on this post and I am sure you will find a good idea. :-)

      Thank you.

      Reply
  24. Nimish Jain

    It is a very good program. Very interactive.
    Hats off to you bro.

    Reply
    1. Adarsh Mehta Post author

      Appreciate these kind words, brother Nimish. Glad you took some time to make this wonderful comment.

      Thank you.

      Reply
  25. Alankriti Mallick

    Hello.
    Many many thanks for your idea. I’ve tried it but in scanner class and a little differently. But anyways, thank you very much for the concept of this game. I was finding some simple game to build on java and this is quite nice and easy. So thank you very much!!!!!

    Reply
    1. Adarsh Mehta Post author

      Happy to help. :)

      And it’s nice to hear that you improved this code by making a few changes on your own. A few people just copy-paste my code as it is and do not work a tad bit on it. Glad to see that you’re not one of them. :D

      Thank you.

      Reply
  26. Ananya puri

    sir, i am not able to understand that how it is logically made by you.I also need to know its alogrithm(steps or the logic applied).

    ill be thank full if help me.

    Reply
    1. POOJA

      ILL BE THANKFUL IF U HELP ME………..
      I AM IN CLASS 10 AND I HAVE TO MAKE A PROJECT (java)ON WORKING OF PAYTM……….

      Reply
      1. Adarsh Mehta Post author

        Hello, Pooja or Ananya (whoever you are).

        Here is a short explanation by me about the program:

        Hand Cricket is a very famous game among the school kids in India and similar countries. In this Java Program that I made about this game, there are two players (one the human player, and other the computer) who will be playing the game, and after performing a ‘toss’, one chooses to bat and the other has to bowl. Both the players will simultaneously signify a number between 1 to 10. If both the players point out the same number, the player who is batting gets ‘out’, else, this is repeated and whatever number the batting player (batsman) keeps throwing are added and that becomes his/her score.

        After the batsman gets out, the bowling player (bowler) becomes the batting player and vice-versa. Now, the process is repeated again and finally, if the original bowler scores more than the original batsman, he/she wins. If they both score the same runs and both get ‘out’, then it is declared as a tie. If the original batsman scores more than the original bowler, he wins.

        In my program’s source code, the user is first batting and he/she is asked to enter a number. That number is stored in the variable ‘bb’. After that, a random number between 1 to 10 (including both 1 and 10) is generated using some mathematical adjustments and functions and stored in the variable ‘aa’. Using if-else, then, it is checked if bb is equal to aa or not. If they are equal, the user is declared as OUT. If they are not equal and the user’s input is between 1 to 10 (including both 1 and 10), then the number entered by the user is added to his/her total score (in the variable ‘score1’). Once the user enters the same number as the computer has generated, he/she is declared OUT and then the computer goes to BATTING.

        After that, still, the numbers entered by the user on each THROW is stored in the variable ‘bb’. The random numbers are still stored in ‘aa’. Now, if the number entered by the user is equal to the number generated by the computer, the computer is declared as OUT. If they are not equal, then the number generated by the computer is added to its total score (in the variable ‘score2’). Once the user enters the same number as the computer has generated, the computer is declared OUT and then the FINAL SCORES of both the players are compared by comparing the variables ‘score1’ and ‘score2’.

        Whoever scored the more, WINS! If they both scored the same unluckily, it is a TIE. :D

        Hope you found this useful. And good luck with your project on PAYTM. :)

        Thank you.

        Reply
  27. Aditya

    Sir I have made a game based on string handling and related to it. I wished I’d you can just run it and see how it is I m in class 10 ICSE. So can you give me your id to mail the file.

    Reply
  28. Mohit Chandra

    I cannot understand how to run this program… Means that I complied it but not able to run it…

    Reply
    1. Adarsh Mehta Post author

      Hello, Mohit.

      Please watch this video and see if you are doing anything wrong.

      https://www.youtube.com/watch?v=WZT4b0wJ5co

      If after watching the video you are still not able to compile and run the program, then please explain your problem and the error faced by you in detail by replying to this comment and I will be more than happy to help. :)

      Thank you.

      Reply
  29. Simran

    Could you please get the variable description of this program….. Its really urgent

    Reply
    1. Adarsh Mehta Post author

      I have already put most of the variables’ basic purpose and description in the program source code itself. Please check out the program source code. It is written as comments beside the first declaration of each and every variable.

      Hope this helps. If you still have any doubts/queries, do not hesitate to reply. :)

      Thank you.

      Reply
      1. Simran

        Ok thank you so much, this project helped me a lot to get through my internal marks for my board examinations……. Thank you so much

        Reply
  30. Vrishank Khanna

    Bro I would want to know what is your reason of using buffered reader instead of scanner class anything specific and what would be the programme code in scanner class because I have failed converting it to scanner class and I don’t understand buffered reader

    Reply
    1. Adarsh Mehta Post author

      Hello, Virshank. There is nothing specific and you can use any one of the options: Buffered Reader Or Scanner for this program.

      I have used Buffered Reader because I know how to use and I do not know as much about Scanner. :D But Scanner is generally beneficial and better than Buffered Reader in these types of cases.

      So, please visit the below link to understand how to use the Scanner class:

      http://www.cs.utexas.edu/users/ndale/Scanner.html

      Also, do visit this link if you wish to know several points of comparison between Scanner and Buffered Reader:

      http://stackoverflow.com/questions/2231369/scanner-vs-bufferedreader

      Thank you.

      Reply
    2. Calvin Peltier

      I have a similar Hand Cricket program (not based on this method) which I coded myself. It uses ‘scanner’ and also has various other choices like heads/tails toss, cheats etc. If you want to see how the program works with Scanner, do let me know.

      Reply
      1. Adarsh Mehta Post author

        Sure, Calvin.

        I would love to see your program and I am sure others will too. This is a very nice innovation from your side. Please post a link to your program’s source code right here in the comment section and help out our fellow readers! I will surely give you full credit for your program. :)

        Thank you.

        Reply
  31. Rohit Patidar

    Hi Adarsh Mehta
    You had made a wonderful program of cricket. My teacher so happy to see this program .
    Thank you

    Reply
  32. K. S. Pranati

    It’s really a fantabulous webpage…!!!!!!!!! As it gives an idea how to play hand cricket for new learners……

    Reply
    1. Adarsh Mehta Post author

      Yes, you are very correct Pranati!

      Before writing this post, I did give a lot of thought about whether posting this would hinder the learning process of the students – as they will be able to copy and paste this project and not learn anything because they would not work hard on their own. But then, of course, I came to the conclusion that those who wish to learn will learn and those who wish to escape hard work and copy-paste will find some or the other way to do that.

      And, after seeing all these comments, I am glad to know that students are not just copy-pasting this Java Program but understanding it in detail and asking nice doubts in the comments section as well as on email. Glad you liked it too! :)

      Thank you.

      Reply
  33. Ishaan Saklecha

    Work appreciated..
    God bless..
    This program of yours helped me alot..
    Thank you so much!

    Reply
  34. Riddhima

    Thank you so much for your help this program helped me alot earlier. I was wondering that how I will make my project but now its done.
    I really loved your creation your program was awesome and very easy to understand. I never faced any problem throughout the program.
    Thank you soooo much.

    Reply
    1. Adarsh Mehta Post author

      I hear that all the time but it never gets old. :mrgreen: Glad to have helped you out! I wish you good luck in all your future endeavours. :)

      Thank you.

      Reply
  35. Riddhima

    I just have to write 2 paragraphs.
    I will be really grateful to you if you will do this for me.
    Thanks a lot.

    Reply
    1. Adarsh Mehta Post author

      SCOPE.

      This Hand Cricket program written by me has a wider scope than one may imagine. Hand Cricket is a very famous game among all the school kids in India and similar countries. School students play it a lot with their friends on a regular basis. This program allows everyone to play the same Hand Cricket game without the need of any other person. So, if someone is alone and still wants to play Hand Cricket, this program offers him/her that opportunity. Also, playing Hand Cricket against Computer interests many people and is quite entertaining and addictive. This program serves that purpose as well.

      The Hand Cricket program is also, inter alia, a decision maker. So, if someone is not able to make a decision by himself/herself, he/she can play with the Computer, assign the two choices to win or lose, and make his/her decision. One may argue that this is not a good way to make decisions, but still, it is being practiced by so many people around the world. So, after reading this, you should be able to make out that the Hand Cricket program’s reach is pretty good and it can be seen as a precursor to more complex and better games in Java language.

      Thank you.

      Reply
  36. Riddhima

    I need to submit my project on Saturday, plz can you provide me with a written scope of the program?

    Reply
    1. Adarsh Mehta Post author

      I could do that if you would be so kind to give me a format and the length of the scope of the program that I have to write for you.

      Thank you.

      Reply
  37. Krishna

    I have made the input limit hundred and the computer number limit as 100 so that I could get a little kick in playing the game…!!! This is an awesome code!!! Fun in playing…

    Reply
    1. Adarsh Mehta Post author

      Hahahaha, that surely will make the game very long and risky… Enjoy!!! :D

      I am glad you found my code “awesome”!!! 8-)

      Thank you.

      Reply
      1. Nasrullah

        what to do if you want to change limit of input numbers please tell

        Reply
  38. Avishi

    Thank you so much for this program. My friends and I had spent quite a lot of time writing a program for hand cricket, but had a few problems coming up. This code runs perfectly fine. You really did solve our doubts. I have a question by the way… Here the batsman can score between 1 and 10. If I want the runs between 1 and 6, will multiplying the random number generated with 6 work?
    And yes, thanks on behalf of my friends too. :)

    Reply
    1. Adarsh Mehta Post author

      I am very happy to hear that this program helped you all out! :)

      And yes, if you want the runs to be between 1 and 6 (including both the numbers), you can just multiply the randomly generated number by 6, add 1 to it, and then convert it to an Integer. It will work! In fact, you can give the user an option of choosing the range of numbers (like 1 to 9, 1 to 11, and so on) rather than fixing the range of numbers in the program. You can also add more cool features like Odd-Eve toss (for batting or bowling).

      Have fun.

      Thank you.

      Reply
  39. Amita

    I am a parent of Xth class student – she has taken Computer Application…

    Reply
  40. Manju

    Hello sir,
    I am not understanding why have you used cheat variable in the program in so many places… Can you please explain…???

    for(c=0;c0)
    //{
    // break;
    // }
    System.out.println(“====================================”);
    }

    for(c=0;c0)
    // {
    // break;
    // }
    System.out.println(“YOU ARE BOWLING:”);
    }

    for(c=0;c0)
    // {
    // break;
    // }
    System.out.println(“====================================”);
    }

    for(i=1;i>0;i++)
    {
    if(cheat>0)
    {
    break;
    }

    for(c=0;c0)
    {
    break;
    }

    System.out.println(“====================================”);
    }

    for(i=0;i0)
    {
    break;
    }

    Reply
    1. Adarsh Mehta Post author

      Sure, Manju. It is pretty simple.

      I do not want the user to enter a number which is not a number between 1 and 10. So, if the user enters a number which is not a number between 1 and 10 (say 13), the “cheat” variable becomes greater than 0. And I have put conditions everywhere that if cheat>0, then do not execute that block of code. So, basically, when cheat becomes greater than zero, the programs ends.

      You can change this if you want a give the user a chance to enter a new number again, rather than just ending the program.

      This is the best I can explain this. If you are still not able to understand, then may God help you. :D

      Thank you.

      Reply
        1. Adarsh Mehta Post author

          Dear Akaash, the variable named ‘cheat’ is used so that the player does not enter any number less than 1 or any number greater than 10.

          So, for example, let’s say the player enters 13, then ‘cheat’ variable’s value changes to 1 and the program ends.

          Math.random() function is just used to generate a random number.

          Hope this helped you out.

          Thank you.

          Reply
  41. Biju

    I still could not understand the function of ‘cheat’… I am not able to understand why it is being used and what is its role… Could you please clear my doubt…???

    Reply
    1. Adarsh Mehta Post author

      Hello, Biju. Surely I would love to clear your doubt.

      I ask the player to enter any number between 1 to 10 (including both). Now, if he tries to act over smart 8-) , and enters, say 20, the ‘cheat’ variable becomes 1. And if you notice, everywhere I have put a condition which checks if ‘cheat’ variable is greater than 0 or not. If it is greater than zero, then “break;” is executed and the remaining part of the program is not executed (because in every part of the code, I have put a condition that if ‘cheat’ > 0, then break).

      So, only a message is displayed, saying, “You have either tried to cheat or entered a wrong input. Game Over!”. And then the program ends.

      You can modify this if you do not like it. You can set it so that if the user types wrong input by mistake, nothing happens, the game does not end and it still continues. :)

      I hope it is cleared now.

      Thank you.

      Reply
  42. Vijetha Vhravya

    Do you have any suggestions for creating an additional feature in the above program by adding the odd or even (coin part or toss). This is supposed to be included in the starting. Could you please gimme some ideas?

    Reply
    1. Vijetha Shravya

      Sir, I also do not have any idea about how to include appropriate error handling in my hand Base Ball Program.
      I’d be very grateful if you would give me some tips on using try and catch blocks in this program in BlueJ. I’m in 10th by the way.

      Reply
      1. Adarsh Mehta Post author

        Hello, Vijetha.

        You will have to learn the try and catch function yourself and apply it to this program. I am sure it won’t take much time.

        I do not have much knowledge about try and catch functions, and because of that fact, I am unable to use them. So, what I do to cover up for that is, I try to eliminate the possibility of errors. Check out my new post: Cool Number Guess Magic Trick Java Program. In that, I have basically eliminated almost all possible errors.

        To eliminate all possible errors, here are the things I have to do:

        1. Accept the user’s input as a string.
        2. Using .equals() function or any other function (if you know any other), compare the string to the numbers 1, 2, 3, and so on.
        3. If it matches with any of those numbers, another integer variable, say ‘r’, becomes r = r + that number which was matched. This ‘r’ variable stores the runs.
        4. If it does not match with any of those numbers, then obviously the user has typed wrong input and you can display an error message saying WRONG INPUT and then either close the program or ask him again to enter his number.

        This process does make the code lengthier but comes in handy for people like me who only know the basic functions of Java. :P

        Now, coming to your first problem. I see that you want to add ‘Odd’ or ‘Even’ toss to this program. Well, it is lengthy but very simple. First, ask the user to select ODD or EVEN. Then, tell him to throw a number. Now, generate a random number out of 1 or 2. Add the random number generated to the user’s input. Check using the % function if the remainder after dividing with 2 is 1 or 0. If it is 1, it is odd and the player will choose if he wants to bat or ball, else, the computer will do so. Again, the computer can choose bat or ball by generating a random number (number 1 and number 2 only, no need to generate 10 random numbers). You will probably have to create new two variables (say ‘j’ and ‘k’). Put the YOU ARE BATTING part of the program in a loop with a condition that it only runs if ‘j’ is 1. Put the YOU ARE BOWLING part of the program in a loop with a condition that it only runs if ‘k’ is 1. Put these both loops created by you in another big loop. Now, according to your toss, decide which part of the code should run first by changed the respective variable’s value to 1 first, and then you can run the other part of the code left afterward using that big loop. :)

        I hope you didn’t lose me there. :mrgreen:

        Thank you.

        Reply
        1. Vijetha Shravya

          Thanks a lot!
          I also don’t know why you have used this array called ‘args’.
          Should i create a different class for the toss thingy to reduce the complexity?

          Reply
          1. Adarsh Mehta Post author

            You are welcome dear. :)

            I normally like to stick to one class (because I have never even used two classes together and do not know how to do it, lol) and would recommend you to do the same. I do not think it increases the complexity in any way (it might make the program look untidy). You can do whatever you like, though.

            I do not remember why we used to have String args[] in the program. I just followed it as a convention. :D Please check out this link to know more about it:
            http://stackoverflow.com/questions/890966/what-is-string-args-parameter-in-main-method-java

            Thank you.

  43. Biju Jacob Thomas

    Could you please send me a source code for rock paper scissors?

    Reply
    1. Adarsh Mehta Post author

      I have not written any code on Rock-Paper-Scissors.

      I had only suggested Soumyaa, in the comments, a few topics on which she could make her Java project, one of which, was Rock-Paper-Scissors.

      Sorry to disappoint you Biju.

      But it is not at all complicated to write a code on it. I would urge you to do it yourself. Just ask the user to enter ‘R’, ‘P’, or ‘S’. Generate a random number from the computer’s side (only 1, 2 or 3) and assign each number to a different weapon. Use if-else condition statements to count the scores and you may limit the total scores (for example, the first player to score 10 wins).

      Thank you.

      Reply
    2. Adarsh Mehta Post author

      I received your email Biju, asking me how to generate a random number between 1 and 3.

      Well, long story short, you can use the following piece of code to generate a random number (natural number only) between 1 and 3 (both inclusive):

      double a=(Math.random())*3;
      int b=(int)a+1;

      I hope this satisfies your queries.

      Also, I recently published a new post on my blog – Cool Number Guess Magic Trick Java Program. I thought you might find it of some use. It is also a kind of Java project, you can say.

      Thank you.

      Reply
  44. Biju

    Sir, I am a student of 10th grade.

    I was going through your hand cricket coding. I have a few doubts. Kindly clear them.

    They are:

    1. What is the function of cheat and why have you done cheat++?
    2. Why have you done
      “rr=((Math.random())*10);
      rr=rr+1;
      aa=(int)(rr);”?
    Reply
    1. Adarsh Mehta Post author

      Hello, Biju.

      I am glad that you have decided to understand my program completely and not just blindly copy it. I admire that. :D

      I have tried my best to clear your doubts below:

      1. As mentioned in the comments written by me in the program itself, the function of the ‘cheat’ variable is to end the game right away if any wrong input is entered. So, for example, if someone enters 11, the game ends right away! In the program, ‘cheat++’ is done so that the value of the ‘cheat’ variable becomes 1. Inside every loop, I have inserted a checker which checks if the value of ‘cheat’ is greater than 0 or not. If it is 1, that loop is not executed (break function is used for this purpose). So, after the user types a wrong input, ‘cheat’ becomes 1 and after that, none of the loops are executed and the program ends.
      2. Using the math.random() function, a random number is generated between 0 and 1. This random number that is generated is not an integer because it is in decimals (in the form of ‘0.something’). So, I have multiplied it by 10 to make it a number in the form of ‘2.something’ or ‘7.something’ or ‘9.something’. Because it is in this kind of form, I had to declare the ‘rr’ variable as a ‘double’.
        Now, the random number generated before was only between 0 and 1, and did not include 1 itself. So, ‘rr’ could be ‘0.something’ or ‘9.something’ but not ’10.something’. Because of this fact, when I used the ‘aa’ integer variable to convert the ‘rr’ number to an integer, it could turn out to be zero sometimes! Also, it could never turn out to be 10. Because of this reason, I have first added 1 to the ‘rr’ and only then proceeded to convert it into an integer. After doing all this, now the number could never be zero and could be ten.

      I hope you understood my explanation and are satisfied with it. :)

      Thank you.

      Reply
  45. Soumyaa

    Hi sir… I am Soumyaa and I’m in 10th.
    I am making a java project on games… And I need to make 3 games at least…
    I have managed 2 (hand cricket and the other on memory boosting).
    Then I thought of tic tac toe… But that would make the programme too big…
    Can you please suggest such a game that is not too long… It would be kind of you…
    And thanks a lot for the hand cricket program… :)

    Reply
      1. Adarsh Mehta Post author

        Hello, Soumyaaaaa :D

        Tic Tac Toe is a great great idea for a student at your level. So I would urge you to do it. I do not think it would turn out to be very lengthy or difficult. I think you would be fine just using three arrays containing three elements each to simplify it. I guess it would take you around 12-14 hours in total to make it (unless you are a slow typer ;) ).

        But, I do not want to leave you hanging. So, if for some reason you still do not like the idea of implementing Tic Tac Toe in your project, here are some other unique Java Game project topics from my side (I could only think of these four :-( ):

        1. Hangman (Again, it is not as complicated as it seems at first look to program it).
        2. Math Calculation Challenge (Different math questions, starting from easy ones and then getting tougher and tougher as the user proceeds. You could even ask the user to set a timer while he plays the game).
        3. Coin Toss. Dice throw. Other small things. All combined into one feature providing game.
        4. Rock-Paper-Scissor. :mrgreen:

        I hope you select the one which suits you best!

        Thank you.

        Reply
        1. Soumyaa

          Thanks a lot sir… I think I should be going for tic tac toe only…
          And sir, the other options are quite relevant but hangman has already being chosen by one of my classmate and maths calculation too…
          And rock paper scissors would be somewhat similar to hand cricket…
          And sir please one more help…
          I have made the program only tic tac toe part isn’t there…
          I wud like you to have a look at it and tell me if there is any flaw in it…
          If you have time I would be glad to mail it to you…
          So please give me your mail id…
          And once again, thank you…

          Reply
          1. Adarsh Mehta Post author

            I received your mail Soumyaa.

            I do not have enough time to constructively analyze your program. So, I just ran it in BlueJ and tried to play the first two games multiple times.

            There are many many problems in your program. I do not have time to list them all in this comment, but here are some of them:

            • In Memory game, even when I enter the right numbers, the score becomes 3 and in the next round it always (as far as what I experienced) becomes 0.
            • Instructions do not match with what is really happening in your program.
            • In Hand cricket, I am not able to play. It asks for parameter, then asks ‘Odd’ or ‘Even’, and then asks to enter a number, and when I do that, the game ends!
            • Formatting is pretty weird and unsystematic. It’s not necessary to change it, but making it look systematic and clear makes the program more elegant.
            • So basically, both your games (number 1 and number 2) are not working properly. And you have not made the third game (Tic Tac Toe). So, your project is a complete failure. :mrgreen: Just kidding.

            I hope you have enough time to fix all these problems. I would really recommend dropping the idea of Tic Tac Toe if you can, and focusing on making the project with these two games only, and making them perfect. I remember I had only two games (Quiz and Hand Cricket) in my project during my school days, but they were 100% perfect. And I can assure you, I got EXCELLENT marks!

            I am sure you won’t need my help from now on (I don’t have any time to help anyways till November 8th), because you can just run your program yourself and try different possible inputs to see if your program is able to handle them all and work correctly no matter what input is entered.

            I hope you got my point.

            Thank you.

          2. Soumyaa

            Sir, I got your point
            and the errors have been sorted out
            and the toss thing was like the toss we do in normal play…
            Choose Odd or Even number,
            take out random numbers and just add them up… It was just the thing that my instructions were not clear…
            Thanks for your help… And yeah now don’t require any help…

          3. Adarsh Mehta Post author

            I know what the toss thing is in Hand Cricket Soumyaa. I liked your idea of implementing such a nice feature into that game.

            And in my previous comment, I was just mentioning that after running the code you sent me, after playing the hand cricket game, after selected Odd or Even and after entering a number, the game would just end. Maybe in the code you sent me, you had not completed the toss part. I haven’t had any time to check that.

            Anyways, good luck with your project. :) Hope you sorted everything out properly.

            Thank you.

          4. Soumyaa

            Yeah its all done.
            As you know in programing smallest error can make a huge difference!
            And all the best for your studies… And exams…

  46. Srujana

    Sir, I want the source code or at least the rough draft for hospital management.

    Reply
    1. Adarsh Mehta Post author

      Hello, Srujana.

      Here is the semi-complete draft code I have written on hospital management just for you (and two other people): :D

      http://pastebin.com/V1Dmsq3s

      Also, here is an image demonstrating a basic understanding of what has been implemented in the code by me:

      https://www.theadarshmehta.in/blog/Extra-Images/Hospital%20Management%20Program%20Idea.jpg

      I am pretty sure that now you can make progress on your own and do not require any further help of mine. But feel free to contact me in case you face any serious errors or have any major doubts. :)

      Thank you.

      Reply
  47. Arjun

    Write a code in Java.

    There is an India-Pakistan ODI cricket match happening next month! BCCI has received 200 tv ads from companies to be shown during the match. The ads are of variable lengths between 10s and 59s. The total duration of ads to be shown in the match is 120 minutes.

    Please help me, anybody knows this code?

    Reply
    1. Adarsh Mehta Post author

      Sounds like an interesting topic Arjun.

      I did not fully understand what you have tried to explain, but from what I understood, I think, you will have to use arrays. Sounds not very complicated and you should be able to do it all by yourself if you have a proper understanding of arrays and other basic Java functions.

      It is a time-consuming topic though and I do not have enough time right now brother. So I would not be able to help you out in any way. Hope you understand.

      I really wish someone else reads your comment and decides to help you out.

      Thank you.

      Reply
    2. Soumyaa

      You can use null loops for the ads.
      Like I have one for you:

      for (long crs=0; crs<=99999999; crs++)
      for (long cs=0; cs<=5; cs++);

      This gives a pause of 22 secs (roughly).
      You can now play up with the values of ‘crs’ and ‘cs’ and time it.
      Although I don’t think you would need, you can use ‘n’ number of nested loops…
      Hope this was a help…
      Thanks.

      Reply
      1. Adarsh Mehta Post author

        Brilliant idea Soumyaa!

        I remember now that during my school days, our teacher gave us this idea so that we could use it for time-related programs in our projects.

        I had totally forgotten about it but thanks to you, my mind has been refreshed. :)

        Thank you.

        Reply
  48. Elina

    Can you help me…???
    Can you please send me the sample program in hospital management system…???

    Reply
    1. Adarsh Mehta Post author

      Hello, Elina.

      Earlier, I had sent Ansh a semi-complete draft code about hospital management system and also an image showing what I have done in that code, via email. :)

      I have sent the same to you via email. Please revert back when you find the same.

      Thank you.

      Reply
      1. Pranathi

        Can you please give me some ideas for a project, please!!!
        I beg of you…
        Though, I know how to do it, I’m black about ideas…
        Please help me out Adarsh Mehta.

        Reply
        1. Adarsh Mehta Post author

          Hello, Pranathi.

          I am quite appalled that you are not able to think of any good idea for your Java project. I am pretty sure if you surf the internet and spent an hour or two, you will be able to find a great topic for your Java project all by yourself.

          Nevertheless, here are some of the Java project topics (for ICSE 10th standard students) that I could think of after reading your comment:

          1. Automatic Teller Machines (ATM)
          2. Theater Ticket Sales
          3. Railway Reservation
          4. Calculator (with a lot of functions)
          5. Net Banking (mobile app) or Net Banking (online)
          6. Complicated Quiz
          7. Online Bus Reservation
          8. Hospital Management System
          9. Any kind of ‘Number Game’ or any type of ‘Number Magic Trick’ which you can implement in a Java program

          These are all the topics I can think of right now. I would urge you not to get annoyed over the fact that you are not able to think of an amazing unique topic for your Java project. Get over it. It is not compulsory to choose a unique topic. I hope you understand.

          Thank you.

          Reply
  49. Ayush Rai

    Hello Adarsh Sir,
    Can we do player vs player in hand cricket project in Java?

    Reply
    1. Adarsh Mehta Post author

      Yes, Ayush, you most certainly can!

      It is fairly simple to implement player vs. player in my code.

      You just have to remove the parts of the code where a random number is generated and is displayed on the screen saying, “Computer’s Number”. In place of that, put a readLine function and assign a new variable which reads what integer the second player types. And of course, you have to make some other small adjustments accordingly.

      I hope you understood what I tried to explain.

      And by the way, player vs. player makes no sense because both the players will have to sit in front of the computer, so they both will be able to watch what the other player is typing! You will either have to make them turn on their backs every time the other player types or believe in their honesty, LOL. :D

      And as always, if you face any problems in implementing it, feel free to reply back!

      Thank you.

      Reply
  50. Rajiv

    Sir, please make a program on restaurant including arrays. It would be a great help to get ideas from your great programming skills. I hope you will reply soon.

    Reply
    1. Adarsh Mehta Post author

      Brother Rajiv, I would love to help you out, but I do not have enough time. I have my IPCC exams coming soon for which I have to prepare. Also, I have many other routine works because of which, I won’t be able to devote much time to writing a code specially for you. :(

      Here is a rough idea, though: :D

      1. Give a menu to the user consisting of various food items.
      2. Associate with every food item, its amount, using arrays.
      3. The user must be able to add food items to the cart.
      4. The corresponding amount of the food which the user is adding to the cart must be calculated and totalled by you simultaneously using a variable or something.
      5. The user must be able to view his cart and remove items from it or add more items.
      6. Service tax must be calculated separately to make your code look professional.
      7. All these things must be done using arrays because that will make it easier and professional.
      8. If you can, also provide a discount code option.
      9. You probably will have to use ‘for’ loops, ‘if’ and ‘else’ condition branches, etc. as well if you want to implement everything I said into your program.

      I hope you got a rough idea. Now, you should be able to write the code on your own. If you are not able to write it on your own, you must not be good at coding, in which case, stick to an easy project topic. It is not necessary that you make a complicated and hard project. Just make something which you completely understand and you will do just fine. :)

      And of course, if you need any help or have any doubts, feel free to contact me through the contact form or through my email id. But I probably won’t be able to reply within a reasonable time period as I am busy for the following 2 months. :(

      Thank you.

      Reply
  51. Mithilesh Patil

    HELLO ADARSH SIR, I AM DESIGNING HAND CRICKET GAME PROGRAM WITH MY DIFFERENT LOGIC. IF YOU DONT MIND, CAN I SHARE MY PROGRAM WITH YOU? AS I AM MODIFYING IT. YOU SUGGESTED ME 7 TOPICS, BUT I DIDN’T GET THE 4TH TOPIC. CAN YOU EXPLAIN ME THAT TOPIC AGAIN?
    THANK YOU.

    Reply
    1. Adarsh Mehta Post author

      OKAY, FIRST THINGS FIRST. YOU DO NOT NEED TO TYPE LIKE THIS. :mrgreen:

      Now Mithilesh, you can do whatever you like with this code. It has been made available to the public by me without any restrictions. And feel free to share your modified version with me through the contact form on this blog or my email id.

      Also, I am sorry to have explained the 4th point so badly. It basically means accepting a word from a user, say ‘Ell’, and displaying it like this maybe:
      ___
      |__
      |___

      |
      |___

      |
      |___

      There are endless possibilities, but you get the idea, right?

      You can visit the following links to get some more information and examples regarding this type of ASCII Art:

      http://www.network-science.de/ascii/

      http://patorjk.com/software/taag/

      http://www.kammerl.de/ascii/AsciiSignature.php

      Looking forward to hearing from you soon. :)

      Thank you.

      Reply
  52. Mithilesh Patil

    HELLO ADARSH SIR, I AM IN GRADE 10 AND I HAVE TO DESIGN A GAME. CAN YOU SUGGEST ME A FEW IDEAS?

    Reply
    1. Adarsh Mehta Post author

      Sure, Mithilesh.

      Here are some of the few topics you can base your projects on:

      1. Complicated Quiz (have some lifelines, different stages, etc.)
      2. Hand Cricket (you can complicate it by adding team options)
      3. Multiple Units Converter (for example, Celsius to Fahrenheit, Miles to Kilometer, and so on; not exactly a game but still a very good idea if you can put a lot of options)
      4. Pattern Generator (if you are smart and spend a lot of time on this, you can create a program that beautifully converts what the user types into a ASCII Art; but of course you will have to use only the program codes which are in your syllabus, so it will require a lot of time and experimentation)
      5. Hangman Game (if you do not know what Hangman is, Google it; it is a very great idea if you manage to do it properly in your project) ;)
      6. Word Messer (a program that accepts a word from the user and then gives various options like count vowels, check if the word or sentence is a palindrome or not, convert it to Pig Latin, and so on; it is very easy to make, so make sure you provide a hell lot of options to the user!)
      7. ULTIMATE Combinations (you could also make a program where you provide the user to choose from the six game options mentioned above; this would make the program very lengthy but also the best in your class) :D

      Finally, I would like to add that please do not think a lot about your topic. They do not give a lot of importance to your program code at this stage. So just make something nice and unique. Have a fine understanding of your work and you will do just fine! :)

      Thank you.

      Reply
      1. Nasrullah

        hello adarsh dude, i have atlast scored a century on the hand cricket thanks for this awesome game man.please create more interactive games like this

        Reply
  53. Ansh

    Sir can you make a code on ‘hospital management’, which accepts details of patients, diseases etc. I am in 10th and I don’t have any idea about my project.

    Reply
    1. Adarsh Mehta Post author

      Dear Ansh, I surely CAN make a program on Hospital Management, but I won’t. Because even you should be able to do that if you have a proper understanding of Java programming.

      And it would not be nice of me to make a project just so that you can get marks. That will not make you learn and explore new things in Java programming.

      Please understand that it is not necessary to make an amazing project to get full marks. Just make something simple and unique and perfect and have a full understanding of it. The examiner will grant you perfect marks if you do so.

      I hope you understand and I wish you All the Best of Luck in all your endeavours. :)

      Thank you.

      Reply
      1. Ansh

        Sir could you please make a draft code for me to work on?
        And once I modify that code, I’ll send it to you first.

        Reply
        1. Adarsh Mehta Post author

          I have done what you asked of me. Please check your email. I have sent you a semi-complete draft code and also an image showing you what I have done in the code. I hope you are satisfied. :)

          Thank you.

          Reply
  54. Mohak War

    Hi Sir,
    I loved your creation, but sir, can I ask for your help for making the program better, adding something like array? Or to play for ten people which make the program look better.
    For eg :-
    Sachin 10 Runs
    Rahul 100 Runs
    Etc.
    And even for different number of players each side!
    I am a student of Grade 10 and I am given a project to make a game and I loved your program.
    I need to submit it on 5 September.
    Please help sir.
    Thanks.

    Reply
    1. Adarsh Mehta Post author

      Hello Mohak.

      I am glad that you liked my creation.

      I like your idea of making this program better by introducing the option for multiple players to play the game. It can be implemented easily. Sadly, I am not fluent with Java programming language right now as it has been two-three years since I last used it. Also, it would make the program code very lengthy and complicated to normal people. Because of these two reasons, I am not gonna be spending any time on implementing your idea and turning it into a creation.

      I would also like you to know that I had submitted my project (three years ago) consisting of just this Hand Cricket game and a Quiz game (two games in one project) and I got full marks in my project. A lot of my friends did. You just need to have a perfect unique project, have a full understanding of each and every line of your code, answer the questions they ask properly with confidence, and you will be awarded proper marks. You do not need to worry. :)

      Sorry for replying so late, but if you want, you can still apply the changes you suggested in your project within a span of few hours, all by yourself, and submit your project. Although, I doubt they would even notice your program. In my experience, they will not lay much focus on how great your project is because they have plenty of other students to attend to! :D

      Thank you.

      Reply
    1. Adarsh Mehta Post author

      I am sorry to hear that Taranum. Could you please explain to me what is the error that is being displayed? And which compiler are you using? Please tell me all the details about your problem and I will be happy to help you out. :)

      Also, I have pasted the java program code on this link as well, just in case you had any trouble copying it from my blog:
      http://pastebin.com/J4UJmeLT

      I would urge you to copy that code properly, create a new class in your project (in whatever compiler you are using, preferably BlueJ) and then paste the copied code and then compile it. It should not show any errors. But still, if it does, do not hesitate to contact me.

      Thank you.

      Reply
      1. Taranum

        This is no syntax error but I’m unable to play.
        We have to go to string for the output, right?
        But I am unable to do so. Can you please help me?

        Reply
        1. Adarsh Mehta Post author

          I am not able to clearly understand what you are trying to say Taranum. But since you are so desperate for help, I have uploaded a video of me compiling and running the program in BlueJ from scratch. :) Please open this link and watch the video:

          https://youtu.be/WZT4b0wJ5co

          Let me know if you still face any issues. I doubt that will happen, though! ;)

          Thank you.

          Reply
      1. Abhimannyu Choudhury

        I want hand Cricket but only runs including 1 to 6

        Reply
        1. Adarsh Mehta Post author

          Abhimannyu, you can use the following piece of code to generate a random number (natural number only) between 1 and 6 (both inclusive):

          double a=(Math.random())*6;
          int b=(int)a+1;

          Thank you.

          Reply
    1. Adarsh Mehta Post author
      • Firstly, this program shows how an idea can be inculcated into a Java program.
      • Secondly, this program could be useful in providing students new ideas for their own project that they have to make.
      • And lastly, this program is a mini game which anyone can play when bored. ;)

      I appreciate you taking the time to read this post, Minakshi. :)

      Thank you.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *