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
Alex17521 [72]
3 years ago
10

Write a user input program that simulates a game of a rolling pair of dice. You can create/simulate rolling one die by choosing

one of the integers values of 1, 2, 3, 4, 5, or 6 at randomly. The number that the user chooses will represents the number on the dice after it is rolled. As a hint use Math.random Which will perform the computation to select a random integer between 1 and 6. Assign the value to a variable to represent one of the dice that are being rolled. Perform this operation twice then you will add the results in order to obtain the total roll. Your program should output the number showing on each dice as well as the total roll. For example:
Computers and Technology
1 answer:
balu736 [363]3 years ago
6 0

Answer:

Follows are the program to this question:

public class Main//defining a class  

{

  public static void main(String[] bax)//main method

  {

       int d1,d2,r;   //defining integer variables  

       d1 = (int)(Math.random()*6) + 1;//defining d1 variables that use random method to store a random value  

       d2 = (int)(Math.random()*6) + 1;//defining d2 variables that use random method to store a random value

       r= d1 + d2;//defining r variable that adds d1 and d2 values

       System.out.println("On the first time die will gives: " + d1);//print values with the message

       System.out.println("On the second time die will gives: " + d2);//print values with the message

       System.out.println("The total roll value is: " + r);//print values with the message

   }  

}  

Output:

On the first time die will gives: 6

On the second time die will gives: 1

The total roll value is: 7

Explanation:

In this code three integer variable "d1,d2, and r" is declared, in which the "d1 and d2" variable is used, that uses the random method to hold a random value from 1 to 6 in its variable.

In the next step "r" variable is declared that calculates the addition of the "d1 and d2", and at the last, it uses the print method to print value with the message.  

You might be interested in
You have been doing a lot of web surfing lately as part of your research for your course and along the way you have noticed a gr
creativ13 [48]

The generated code component that executes on the web server is the following does Laura tell you is NOT a component of the active server page.

a. the generated code component that executes on the web server

<u>Explanation:</u>

Asp technology is where it is a combination of both  HTML and visual basic programming. Asp web pages are executed in server and display as Html to the end-users.

With the HTML coding, only static pages can be developed whereas through ASP web pages are developed and which contains visual basic coding languages and for client-side validates in ASP web pages either javascript or visual basic scripts are used.

Each ASP web pages are compiled at the server end and executed and complied out HTML pages are shown in web pages.

We need to install the ASP component at the server to execute the ASP web pages.

3 0
2 years ago
Finish and test the following two functions append and merge in the skeleton file:
avanturin [10]

Answer:

Explanation:

#include <iostream>

using namespace std;

int* append(int*,int,int*,int);

int* merge(int*,int,int*,int);

void print(int*,int);

int main()

{ int a[] = {11,33,55,77,99};

int b[] = {22,44,66,88};

print(a,5);

print(b,4);

int* c = append(a,5,b,4); // c points to the appended array=

print(c,9);

int* d = merge(a,5,b,4);

print(d,9);

}

void print(int* a, int n)

{ cout << "{" << a[0];

for (int i=1; i<n; i++)

cout << "," << a[i];

cout << "}\n";

}

int* append(int* a, int m, int* b, int n)

{

int * p= (int *)malloc(sizeof(int)*(m+n));

int i,index=0;

for(i=0;i<m;i++)

p[index++]=a[i];

for(i=0;i<n;i++)

p[index++]=b[i];

return p;

}

int* merge(int* a, int m, int* b, int n)

{

int i, j, k;

j = k = 0;

int *mergeRes = (int *)malloc(sizeof(int)*(m+n));

for (i = 0; i < m + n;) {

if (j < m && k < n) {

if (a[j] < b[k]) {

mergeRes[i] = a[j];

j++;

}

else {

mergeRes[i] = b[k];

k++;

}

i++;

}

// copying remaining elements from the b

else if (j == m) {

for (; i < m + n;) {

mergeRes[i] = b[k];

k++;

i++;

}

}

// copying remaining elements from the a

else {

for (; i < m + n;) {

mergeRes[i] = a[j];

j++;

i++;

}

}

}

return mergeRes;

}

4 0
3 years ago
When you use the Filter feature, what appears in each column label
Scrat [10]
<span>an arrow  ..............................</span>
5 0
3 years ago
To accomplish a certain task when you would rsther be doing something else is an example of
fenix001 [56]

Answer:

Self Discipline

Explanation:

his is because you train your brain to do the right thing.

I hope I helped. Thank you for your time.

6 0
3 years ago
The animation industry is solely reliant on 3-D modeling and 3-D virtualization to create the animated movies in the cinemas.
loris [4]
False it is false people also hand draw stuff
7 0
3 years ago
Other questions:
  • What were the first microblogs known as
    12·2 answers
  • Blank are back and forth movement of matter that create sound​
    15·1 answer
  • Who's YouTube creator?
    10·2 answers
  • 50 POINTS &amp; A FOLLOW!
    11·2 answers
  • What does it mean when a computer can't break the rules
    10·2 answers
  • A collection of computers, printers, routers, switches, and other devices
    15·1 answer
  • QUESTIONS Which of the following use cases are suitable for compute-optimized cloud offering? ОА. None of the listed O B. Highly
    12·1 answer
  • What is malware? a type of virus that spreads through a network connection a type of virus that targets programs and files any p
    8·1 answer
  • Describe at least one issue of terrorism that has happened recently.
    14·1 answer
  • Fre.e points enjoy em
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!