DOC PREVIEW
OSU CSE 1223 - PRO4A

This preview shows page 1 out of 3 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

project04a Program allows user to play Rock Paper and Scissors as many times as desired by entering Y until they enter N Program will print amount of games played amount lost amount won and percentage won User must enter Y N Rock Paper or Scissors with correct capitalization and spelling author version 20140923 public static void main String args Scanner input new Scanner System in int playerWins 0 int compWins 0 int gamesPlayed 0 while true System out println Do you want to play Rock Paper Scissors Y N String play input nextLine user terminates game and program prints number of wins losses and percentage of wins if play equals N System out println You played a total of gamesPlayed matches against the computer System out println The computer won compWins matches System out println You won playerWins matches 0 wins when no games are played if gamesPlayed 0 System out println You won 0 of the time break else if gamesPlayed 0 double totalWins playerWins 100 0 gamesPlayed System out println You won totalWins of the time break else if play equals N play equals Y System out println Invalid entry else System out println Welcome to Rock Paper and Scissors System out print Select Paper Rock or Scissors String decision input nextLine System out println Your selection decision int num int Math random 3 0 1 switch num case 1 if decision equals Rock System out println Tie you and the computer selected rock gamesPlayed else if decision equals Paper System out println You win paper beats rock gamesPlayed playerWins else if decision equals Scissors System out println Computer wins rock beats scissors gamesPlayed compWins else System out println decision is not a valid input break case 2 if decision equals Rock System out println Computer wins rock beats paper gamesPlayed compWins else if decision equals Paper System out println Tie you and the computer selected paper gamesPlayed else if decision equals Scissors System out println You win scissors beats paper gamesPlayed playerWins else System out println decision is not a valid input break case 3 if decision equals Rock System out println You win rock beats scissors gamesPlayed playerWins else if decision equals Paper System out println Computer wins scissors beats paper gamesPlayed compWins else if decision equals Scissors System out println Tie you and the computer selected scissors gamesPlayed else System out println decision is not a valid input break


View Full Document

OSU CSE 1223 - PRO4A

Documents in this Course
PRO12A

PRO12A

3 pages

PRO11A

PRO11A

4 pages

PRO10A

PRO10A

3 pages

PRO9A

PRO9A

3 pages

PRO8A

PRO8A

3 pages

PRO7A

PRO7A

2 pages

PRO6A

PRO6A

2 pages

PRO3A

PRO3A

3 pages

CL13A

CL13A

2 pages

CL11B

CL11B

2 pages

CL11A

CL11A

2 pages

CL10A

CL10A

2 pages

CL5A

CL5A

2 pages

Load more
Download PRO4A
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view PRO4A and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view PRO4A and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?