Posts

stone paper scissor with computer

  package com.company ; import javax.swing. *; import java.util.Random ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // 0 for stone // 1 for paper // 2 for scissor Scanner Input = new Scanner ( System . in ); System . out . println ( " select 0 for stone \n 1 for paper \n 2 for scissor" ); int userInput = Input . nextInt (); System . out . println ( "you selected " + userInput ); Random randm = new Random ();     // random no is generated by comp. using the random class int compInput = randm . nextInt ( 3 ); if ( userInput == compInput ){ System . out . println ( "draw" ); } else if ( userInput == 0 && compInput == 2 || userInput == 1 && compInput == 0 || userInput == 2 && compInput == 1 ){ System . out . println ( " you win" ); } ...