1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Hitman42 [59]
2 years ago
14

Create a game that rolls two dies (number from 1 to 6 on the side) sequentially for 10 times (use loop). If at least once out of

10 times the sum of two random numbers is equal to 10, you win, else you loose. You will need to get your own method getRandom(int n) that generates a random number, see below (you can modify it as needed), a loop, and IF statement in the loop that checks if a sum of two random numbers is 10 or not.
Please start your program as follows, similar to what we did in class:
import java.util.Random;
public class UseRandom{
//your method getRandom() is here below, n is a range for a random number from 0 to n
public int getRandom(int n)
{
Random r=new Random();
int rand=r.nextInt(n);
return rand;
}
//code continues here, don't forget your main() method inside the class, and making your own object in main() using "new" keyword.
Computers and Technology
1 answer:
Alex73 [517]2 years ago
8 0

Answer:

Explanation:

The following code is written in Java and loops through 10 times. Each time generating 2 random dice rolls. If the sum is 10 it breaks the loop and outputs a "You Win" statement. Otherwise, it outputs "You Lose"

import java.util.Random;

class Brainly {

   public static void main(String[] args) {

       UseRandom useRandom = new UseRandom();

       boolean youWin = false;

       for (int x = 0; x<10; x++) {

           int num1 = useRandom.getRandom(6);

           int num2 = useRandom.getRandom(6);

           if ((num1 + num2) == 10) {

               System.out.println("Number 1: " + num1);

               System.out.println("Number 2: " + num2);

               System.out.println("You Win");

               youWin = true;

               break;

           }

       }

       if (youWin == false) {

           System.out.println("You Lose");

       }

   }

}

class UseRandom{

   public int getRandom(int n)

   {

       Random r=new Random();

       int rand=r.nextInt(n);

       return rand;

   }}

You might be interested in
Pda bkhhksejc pnwjoynelp dwo xaaj ajykzaz ywj ukq zaykza ep???<br><br><br> The Key Value is 22
Sindrei [870]

Answer:

The following transcript has been encoded can you decode it???

Explanation:

It is a ceasar cipher. Shift every letter in the alphabet by 22 positions.

3 0
3 years ago
A company is completing research and development for software which it is planning to produce in approximately 2 years time. Whi
likoan [24]

Answer:

The transistor density of the hardware which will exist in 2 years time will likely be double the current processing speeds.

Explanation:

The other 3 options are incorrect

7 0
2 years ago
Describe the type of gameplay seen during early video games (ex. Spacewar!, Pong).
Elina [12.6K]
  • Sandbox. ...
  • Real-time strategy (RTS) ...
  • Shooter (FPS and TPS) ...
  • Multiplayer online battle arena (MOBA) ...
  • Role-playing games (RPG, ARPG, and more) ...
  • Simulation and sports.

<em>-</em><em> </em><em>BRAINLIEST</em><em> answerer</em>

3 0
2 years ago
Read 2 more answers
Tfuuvj vjiibjoon Ghosh kpj
Nookie1986 [14]

Answer: A

Explanation: For any formal document you need your major points.

5 0
2 years ago
Read 2 more answers
What term is used to describe a list of security policies that is associated with an object?
Artemon [7]

Answer:

An Access control list (ACL) is used to describe a list of security policies that is associated with an object

5 0
3 years ago
Other questions:
  • What to do when the tool bar for paint tool sai dissapears?
    12·1 answer
  • What is not true about contracts?
    12·2 answers
  • How do you put a voice password on your computer using windows 10
    14·1 answer
  • The technology dealing with robots is called
    6·1 answer
  • Listed here are a few camera angles and their images.
    10·1 answer
  • A website for a certain political party or candidate is likely to have unbiased
    6·1 answer
  • In order to create a chart, which of the following must be selected?
    8·1 answer
  • Look at (c), is it accurate? ​
    9·2 answers
  • When planning your App what difficulties did come across and why?
    5·2 answers
  • Define technical writing. The proposal introduces the ……. (5 Mark)
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!