Question
Use a text editor to create a comma-delmited file of user IDs and passwords. Revise the program below so that the user must first enter
Use a text editor to create a comma-delmited file of user IDs and passwords. Revise the program below so that the user must first enter a correct ID and its associated passwords before playing.
package rockpaperscissors;
import java.util.Scanner;
public class RockPaperScissors
{
public static void main(String[] args)
{
int computer;
int person;
System.out.println("1 = Rock");
System.out.println("2 = Paper");
System.out.println("3 = Scissors");
computer = ((int)(Math.random() * 100) %
3 + 1);
Scanner input = new Scanner(System.in);
System.out.println("Please enter a number");
person = input.nextInt();
System.out.println("You chose" + person);
System.out.println("The computer chose" + computer);
if(computer == person)
System.out.println("The result is a tie");
else if(computer == 1 & person == 2)
System.out.println("You have won");
else if(computer == 2 & person == 3)
System.out.println("You have won");
else if(computer == 3 & person == 1)
System.out.println("You have won");
else if(computer == 2 & person == 1)
System.out.println("You have lost");
else if(computer == 3 & person == 2)
System.out.println("You have lost");
else if(computer == 1 & person == 3)
System.out.println("You have lost");
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started