Last active
February 27, 2026 19:34
-
-
Save YousufProjs-exe/9b3b8116e477877a5673cecdbfd006bf to your computer and use it in GitHub Desktop.
A Fun GUI less Rock Paper Scissors game using Nested Loop and under fundamentals of Java. You will need JDK if opening in any IDE like Visual Studio Code or if your opening it in a bulit in Java Compiler like BlueJ.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| import java.util.Random; | |
| //importing java classes | |
| public class game_1 | |
| { | |
| public static void main(String agrs[]) | |
| { | |
| String options [] ={"Rock","Paper","Scissors"}; | |
| //setting options | |
| Scanner sc = new Scanner(System.in); | |
| Random ra = new Random(); | |
| System.out.println("Enter one of these: Rock , Paper or Scissors"); | |
| String userMove = sc.nextLine(); | |
| //Taking Inputs from the User | |
| int complndex = ra.nextInt(); | |
| String compMove = options[complndex]; | |
| //Random Choice from Computer | |
| System.out.println("Computer choose:"+compMove); | |
| if(userMove.equalsIgnoreCase(compMove)) | |
| { | |
| System.out.println("its a tie"); | |
| } | |
| else if( | |
| (userMove.equalsIgnoreCase("Rock")&&compMove.equals("Scissors")) || | |
| (userMove.equalsIgnoreCase("Paper")&&compMove.equals("Rock")) || | |
| (userMove.equalsIgnoreCase("Scissors")&&compMove.equals("Paper")) | |
| ) | |
| { | |
| System.out.println("YOU WIN!"); | |
| } | |
| else | |
| { | |
| System.out.println("Opps , YOU LOSE"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment