I need to create a simple rock paper scissors program using java, but without a
ID: 3638441 • Letter: I
Question
I need to create a simple rock paper scissors program using java, but without a computer player.Just player 1 inputs R, P or S, and then player 2 inputs R, P, or S. Then it gives a result on who won and who lost. Can anyone help?? I am very new to java.
I know that I don't need to import Random because there is no computer player. And i need to import Scanner to take their inputs.
I'm very bad with java language, I don't know how to take people's string inputs (though i do know how to take integers and doubles), and i need to write a while loop that allows it to keep asking them to retype R, P, or S, if they type something other than those three letters. Also, how would I write the if else statements for the actual processing of their inputs? Like, figuring out who wins?
Additional Details
import java.util.Scanner;
public class RockPaperScissors {
public static void main (String [] args){
Scanner cool = new Scanner(System.in);
System.out.println("Hello Player 1, what is your name?")
____ player1 = cool.next();
System.out.println(Player 1 + ", please enter your choice (P for paper, R for rock or S for scissors):");
____ player1choice = cool.next();
System.out.println("Hello Player 2, what is your name?")
____ player2 = cool.next();
System.out.println(Player 2 + ", please enter your choice (P for paper, R for rock or S for scissors):");
____ player2choice = cool.next();
}
}
this is all i've got. I think i have to use "else if" statements but i've never even used them before...
and i just realized i'm not getting "ints" so... how do i accept "R, P, or S?"
Explanation / Answer
Try now
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.