A java program where the user designates

Assignment Help JAVA Programming
Reference no: EM13165684

a java program where the user designates how many games they would like to play (for example user inputs 10 games) then they play the game, if lets say there is a tie after 10 games the game continues until either the user of the computer wins by 2


This is what I have so far

import java.util.Random;

import java.util.Scanner;

 

public class RockPaperScissors

{

public static void main (String[] args)

{

int Computer=0,Player=0,tie=0,compic,pscore;

String str="y";

Random generate= new Random();

Scanner scan=new Scanner(System.in);

while (str.equals("y"))

{

compic=generate.nextInt(3)+1;

System.out.println ("Enter 1 for Rock, 2 for Paper, and 3 for Scissors");

pscore=scan.nextInt();

if (compic==pscore)

{

System.out.println("Tie No Winner");

tie++;

}

else

{

switch (pscore)

{

case 1:

{

if (compic==2)

{

System.out.println ("Paper beats Rock");

System.out.println ("Computer wins");

Computer++;

}

else

{

System.out.println ("Rock beats Scissors");

System.out.println ("Player wins!");

Player++;

}

break;

}

case 2:

{

if (compic==1)

{

System.out.println ("Paper beats Rock");

System.out.println ("Player wins!");

Player++;

}

else

{

System.out.println ("Scissors beat Paper");

System.out.println ("Computer wins!");

Computer++;

}

break;

}

case 3:

{

if (compic==1)

{

System.out.println ("Rock beats Scissors");

System.out.println ("Computer wins");

Computer++;

}

else

{

System.out.println ("Scissors beat Paper");

System.out.println ("Player wins");

Player++;

}

break;

}

default:

{

System.out.println("Enter 1 2 or 3");

break;

}

}

}
System.out.println ("Ties= "+tie+" Wins= "+Player+" Losses= "+Computer);

Scanner play = new Scanner (System.in);

System.out.println ("Play again? y/n");

str = play.nextLine();

if(!(str.equals("y")))

{

System.out.println ("Scores:");

System.out.println ("Ties= "+tie+" Wins= "+Player+" Losses= "+Computer);

}

else

{

System.out.println ("playing again");

}

}

}

}

 

 

Reference no: EM13165684

Questions Cloud

Compute the theoretical moles of naoh : calculate the theoretical moles of NaOH that should be necessary to reach the equivalence point
Decimal floating point number : What decimal floating point number does this IEEE 754 single precision number represent: 0x47C0_E6B7?
What would be the ieee 754 double precision binary : What would be the IEEE 754 double precision binary representation of the floating point value 2.71828×10-13? Express your final answer as a 16-hexdigit number and explain how your answer was obtained for full credit.
Search for the value needle in the array : Search for the value needle in the array range given by [hay_begin ... hay_end), using the Linear Search algorithm. This function will return a pointer to the needle value if it is found, or a null pointer if needle is not found.
A java program where the user designates : a java program where the user designates how many games they would like to play (for example user inputs 10 games) then they play the game, if lets say there is a tie after 10 games the game continues until either the user of the computer wins by 2
What happens when you assign : What happens when you assign 340,282,343,598.33 to a Single variable? Assuming that the variable in question is named sngNumber and you execute the statement MessageBox.Show
Supposed to swap numbers : The program is supposed to swap numbers, but I am stuck something is wrong! It does not swap them it repeats the second number, please help to fix! Thanks, this is in C++.
The imperial system of measurements : The Imperial system of measurements uses feet and inches for length, where 1 foot is equal to 12 inches. Write a class named Imperial that will represent distance measurements in feet and inches. Your class should include the following.
What do the loops print : What do the following loops print? Work out the answer by tracing the code, not by using the computer. a. int s = 1; for (int n = 1; n

Reviews

Write a Review

 

JAVA Programming Questions & Answers

  Length of the string in order to reserve space

To determine the length of the string in order to reserve space for the new string use the library routine strlen. Register a1 contains a pointer to the string to measure and on return register a1 has the number of characters in the string. You..

  Using an array in java

Using an array in Java - have a list of keywords from a web service and have to print out the list of keywords on the screen with one keyword on each line. This is my code

  Java program that will add the corresponding elements

Develop a Java program that will add the corresponding elements of two 1-dimensional arrays X and Y to produce the 1-dimensional array Z. Arrays X, Y, Z have the same dimension [M].

  Write various bindings to determine semantics

Write the various bindings that are required to determine the semantics when statement is executed. For each binding, indicate binding time used for language. Describe your answer.

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Create four classes

Create four classes: Account.java, Checking.java, Savings.java, and AccountArray.java.

  Afterwards a way for the user to input

And so on and so forth then afterwards a way for the user to input that they finished a particular task on the list. After the user has input that they have finished a particular task the program should be print "Good Job!" or "Keep it up!"

  Write java application to show successive element of array

Write down java application named GoTooFar which declares the array of 5 integers and stored five values in array. write try block in which you loop to show each successive element of array.

  Write a script and verify an logi by reading a file from xl

write a script and verify an logi by reading a file from xl sheet, first time only give the password and get an error message, second time give the email only and get an error message and third time give both email and correct password and get "Signe..

  Drags html list items to and from a javascript array

1.Write a program which drags html list items to and from a javascript array.2. if an identical list item is already in the array, prevent the list item from dropping in the array. Give an error saying that the list item already exists in the array

  Develop class which implements interface

Let the ADT called SquareMatrix. (The matrix can be represented by 2-D array of ints w/ n rows and n columns.) Write specification for ADT as Java interface. Develop the class which implements interface.

  Write java applet for costco gas station

Write a java applet for costco gas station. The applet will first ask you whether you are a costco customer, then the grade of gas you want to use: grade 87, 89, or 91.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd