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]
3 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]3 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
What is output?
postnew [5]

Answer:The French and Dutch settlements differed from the Spanish colonies in that they were created mainly to trade and develop industries, while the Spanish were primarily concerned with gold and silver excavation, and then later with sugar exportation.

Explanation:The French and Dutch settlements differed from the Spanish colonies in that they were created mainly to trade and develop industries, while the Spanish were primarily concerned with gold and silver excavation, and then later with sugar exportation.

8 0
3 years ago
Convert 4.5 strides to girth
n200080 [17]

There are 0.5 strides in one girth
so 4.5 strides will be equal to 9 girth
hope it helps
3 0
3 years ago
List three considerations when you choose memory.
liq [111]
1)How many memory cards (how many can you computer hold)
2)Company (some companies run better than others)
3)Amount of memory (xGb)
8 0
3 years ago
Ang Kabihasnang ito ay umusbong sa rehiyon ng Timog Mexico
Westkost [7]

Answer:

nahh I'm still in disbelieve

8 0
3 years ago
My computer likes to disconnect every 3 or 5 minutes a lot when I turn it on, Is there any solution for this?
stira [4]

Answer:

RESTART IT!!! also check if its charged and look up problems with that model

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • To keep from overwriting existing fields with your Lookup you can use the ____________ clause.
    14·2 answers
  • What is the purpose of a mail merge field?
    12·2 answers
  • Which is considered to be the oldest form of social media? A. media-sharing sites B. location-based services C. social networkin
    5·1 answer
  • What laptops can you get for 2500$ and should mostly using Microsoft applications.
    14·2 answers
  • Java can be used to create which of the following technologies?This task contains the radio buttons and checkboxes for options.
    5·1 answer
  • When you first open a word processor, you’ll find a ? document. A. filled B. blank C. edited
    9·2 answers
  • What is used to connect computers to the internet*Audio Ports
    15·2 answers
  • Stages of reverse engineering
    8·1 answer
  • Select the correct answer.<br> What do you understand by "exposition"?
    10·2 answers
  • Answer the following question in 3-4 complete sentences. Define the following terms: - registration - press - keyblock.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!