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]
2 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]2 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
DES: Group of answer choices A) is a commonly used symmetric encryption B) algorithm that was developed in the mid-C) 1970s was
OLEGan [10]

DES is a commonly used symmetric encryption

A) is a commonly used symmetric encryption

<u>Explanation:</u>

DES stands for Data Encryption Standard. It is a symmetric key algorithm and is used for encrypting electronic data. It was developed in 1975. DES is one of the oldest encryption standards to be used in the industry.

The algorithm takes 16 rounds of permutations in order to encrypt data. But now, with the advent of technology, as new algorithms have been designed and put in use, DES is less preferable.

In the process of key generation, some keys generated sometimes turn out to be weak and hence are prone to attacks. If not for the weak keys generation, DES works perfectly fine and is an effective algorithm to encrypt data.

6 0
2 years ago
Which command compiles the Java source code file Welcome.java?
GarryVolchara [31]

Answer:

javac Welcome.java

Explanation:

In order to the file to compile with the default compiler in the JDK, the instruction must be of the form:

javac filename

(Note: the filename with the .java extension)

3 0
2 years ago
ACTIVITY NO. 5 (DAY 5) FACT OR BLUFF. Write Fact if the statement is correct and write Bluff if it is incorrect.
KengaRu [80]

All of the above are Facts.

preventive maintenance does indeed help with the lifespan etc.

If you are feeling tired or fatigued when operating machinery, stop and rest for fear of mistake. So , two is also correct

4if you dress inappropriately it may cause danger from getting caught in machinery or catching a flame depending on the worksite. so four is correct. Newer models are most likely more updated and have different operations then the last machine. so yes read the manual before using it. so yet again 5 is also correct.

hopefully this helped

3 0
3 years ago
"Save" or "save as" can be used interchangeably and have no unique features.<br> True<br> False
zimovet [89]

Answer:

False.

Explanation:

"save" just preserves any edits made to file in its current state. "Save As" lets you rename it and change the file type.

4 0
2 years ago
Read 2 more answers
What were the technological innovations that allowed for the rapid expansion of the railroads?
liraira [26]

Answer:

There are different phases of railroad expansion with the innovations in technology.

Explanation:

Few of the technological innovations are described below that leads in railroad expansion more rapid.

1. Centralized Traffic control (CTC) is introduced in 1960's that is used to control the traffic on railroads using different signal control.

2. In 1990's after computer technology involvement, railway ticket and reservation system is automate and being centralized. That makes the railroad expansion improve.

3. Bullet train technology has been introduced, that makes the railway trains more faster.

4. Electric trains has been introduced to use green energy and reduce the dependency on the fuel to make environment clean and green.

5 0
2 years ago
Other questions:
  • Create a program that reads words.txt (link near top of our home page) in order to: determine the length of the longest word(s)
    14·1 answer
  • Which of the following is NOT one of the modules of a typical Decision Support System (DSS)? Select one: a. Customer information
    14·2 answers
  • What tasks do most operating systems perform?
    15·1 answer
  • You have noticed that one of your DNS servers has possibly been compromised. You believe that a cached DNS entry for your domain
    8·1 answer
  • For Windows 9x and Windows NT operating systems, which authentication protocol should be used that protects the authentication p
    11·1 answer
  • A provides legal protection for something an individual has created
    12·1 answer
  • Consider an application that transmits data at a steady rate (for example, the sender generates N-bit unit of data every k time
    7·1 answer
  • Match each of the following terms to its definition: I. web-based II. open source III. project management IV. personal informati
    12·1 answer
  • What is the official name of an application on a desktop or a laptop?.
    13·1 answer
  • A technique that was developed to determine whether a machine could or could not demonstrate the artificial intelligence known a
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!