java

Write a program of a game STONE PAPER SCISSOR with computer as oponent and ask the user the no of times he wanted to play and display the result and accuraccy.

Write a program of a game STONE PAPER SCISSOR with computer as oponent and ask the user the no of times he wanted to play and display the result and accuraccy. ( #JAVA )

java

/*
Write a program of a game STONE PAPER SCISSOR with computer as oponent and ask the user the no of times he wanted to play and display the result and accuraccy.
*/

package com.company;

import java.util.Scanner;
import java.util.Random;

public class StonePaperScissors
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        Random random = new Random();

        System.out.println("Press \' 0 \' for STONE");
        System.out.println("Press \' 1 \' for PAPER");
        System.out.println("Press \' 2 \' for SCISSOR");

        double accuracy;
        int TotalTimes = 10;
        int WinTime = 0;

        for ( int i = 0 ; i < 10 ; i++ )
        {

            System.out.println("Input Your Choice :");
            int UserChoice = sc.nextInt();

            if ( UserChoice > 2 )
            {
                System.out.println("INVALID INPUT");
                TotalTimes = TotalTimes - 1;
            }

            else
            {
                System.out.print("Your's Choice is ");
                if ( UserChoice == 0 )
                    System.out.println("STONE");
                if ( UserChoice == 1 )
                    System.out.println("PAPER");
                if ( UserChoice == 2 )
                    System.out.println("SCISSOR");

                int ComputerChoice = random.nextInt(3);
                // System.out.println(ComputerChoice);

                System.out.print("Computers Choice is ");
                if ( ComputerChoice == 0 )
                    System.out.println("STONE");
                if ( ComputerChoice == 1 )
                    System.out.println("PAPER");
                if ( ComputerChoice == 2 )
                    System.out.println("SCISSOR");


                if( UserChoice == ComputerChoice )
                {
                    System.out.println("DRAW");
                    TotalTimes = TotalTimes - 1;
                }

                else if ( UserChoice == 0 && ComputerChoice == 2 || UserChoice == 1 && ComputerChoice == 0 || UserChoice == 2 && ComputerChoice == 1 )
                {
                    System.out.println("YOU WIN");
                    WinTime = WinTime + 1;
                }
                else if ( UserChoice == 0 && ComputerChoice == 1 || UserChoice == 1 && ComputerChoice == 2 || UserChoice == 2 && ComputerChoice == 0 )
                {
                    System.out.println("YOU LOST");
                }


            }      // end of else
        }       //  end of for loop

        accuracy = (WinTime*100)/TotalTimes;
        System.out.println("Accuraccy :  " + accuracy);


    }       // end of main

}       // end of class

Thanks Dosto for Reading this blog.

I think you all are definitely thinking of being connected with me.

Are you??
Yaa I know no-one is here but then also I provide my all social media links of my Digital Creation Tech DCode and my personal handles.
πŸ§‘β€πŸ’»πŸ§‘β€πŸ’» Social Media Links of Tech DCode :

πŸ‘‰πŸ»Β InstagramΒ :Β https://www.instagram.com/thetechdcode/
πŸ‘‰πŸ»Β Facebook PageΒ :Β https://www.facebook.com/thetechdcode
πŸ‘‰πŸ»Β TwitterΒ :Β https://twitter.com/thetechdcode
πŸ‘‰πŸ»Β TelegramΒ ChannelΒ :Β https://t.me/thetechdcode
πŸ‘‰πŸ»Β YouTubeΒ :Β https://www.youtube.com/channel/UCjJnEdeugftBwQ3yMuD4B_A
πŸ‘‰πŸ»Β Tech DCode LinktreeΒ :Β https://linktr.ee/thetechdcode
πŸ‘‰πŸ»Β My Personal HandlesΒ :Β https://linktr.ee/virtualshivamin

 

πŸ§‘β€πŸ’»πŸ§‘β€πŸ’»Β Social Media Links of SHIVAM SINGH (OWNER) :
πŸ‘‰πŸ»Β InstagramΒ :Β https://www.instagram.com/virtualshivamin/
πŸ‘‰πŸ»Β Facebook PageΒ :Β https://www.facebook.com/virtualshivamin/
πŸ‘‰πŸ»Β TwitterΒ :Β https://twitter.com/virtualshivamin/
πŸ‘‰πŸ»Β Personal LinktreeΒ :Β https://linktr.ee/virtualshivamin

🀟🀘 Check Best Offers/Deals and Discount on Amazon :
πŸ‘‰Β AmazonΒ :Β https://amzn.to/3tLt2FN
πŸ‘‰Β BestsellersΒ :Β https://amzn.to/31boSuB
πŸ‘‰Β New RealeasesΒ :Β https://amzn.to/3rdru5U
πŸ‘‰Β Movers and ShakersΒ :Β https://amzn.to/3lFu5nY
πŸ‘‰Β Computer and accessories :Β https://amzn.to/3lERTbJ
πŸ‘‰Β ElectronicsΒ :Β https://amzn.to/3sqHW4l
πŸ‘‰Β SoftwaresΒ :Β https://amzn.to/3ccwAee

 

Leave a Reply

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