Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago