Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HELLO I AM LOOKING FOR THE PSEUDO CODE import java.util.*; public class RockPaperScissors { static String moves[]={rock,paper,scissors}; static Random randgen = new Random(); public static

 HELLO I AM LOOKING FOR THE PSEUDO CODE import java.util.*; public class RockPaperScissors { static String moves[]={"rock","paper","scissors"}; static Random randgen = new Random(); public static void main(String[] args) { Scanner in = new Scanner(System.in); boolean opt=true; int usermove; int computermove; while(opt) {usermove= user(in); computermove=computer(); score(usermove,computermove); opt=conclusion(in); } } public static int user(Scanner in) {char a; int move=0; System.out.print("Choose your weapon (r,p,s): "); a=in.nextLine().charAt(0); a=Character.toLowerCase(a); while(a!='r'&&a!='p'&&a!='s') {System.out.print("Choose your weapon (r,p,s): "); a=in.nextLine().charAt(0); a=Character.toLowerCase(a); } switch(a) {case 'r': move=0; break; case 'p': move=1; break; case 's': move=2; break; } return move; } public static int computer() {int move=randgen.nextInt(3); System.out.println("I chose "+moves[move]); return move; } public static void score(int user,int computer ) { if(user==computer) System.out.println("Tie!"); else if(user==0&&computer==2) System.out.println("You break my scissors. you win!"); else if(user==0&&computer==1) System.out.println("I cover your rock. you lose!"); else if(user==1&&computer==2) System.out.println("I cut your paper. you lose!"); else if(user==1&&computer==0) System.out.println("You cover my rock. you win!"); else if(user==2&&computer==0) System.out.println("I break your scissors, you lose!"); else System.out.println("You cut my paper. you win!"); return; } public static boolean conclusion(Scanner in) {char a; System.out.println(" Good game. Play again!(Y/N) "); a=in.nextLine().charAt(0); a=Character.toLowerCase(a); while(a!='y'&&a!='n') {System.out.print("invalid entry Play again(Y/N)? "); a=in.nextLine().charAt(0); a=Character.toLowerCase(a); } if(a=='y') return true; else return false; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

Describe how oxygen debt may develop.

Answered: 1 week ago