Click here to Skip to main content
15,887,434 members
Home / Discussions / Java
   

Java

 
GeneralRe: Netbeans Pin
Richard MacCutchan15-Mar-20 3:49
mveRichard MacCutchan15-Mar-20 3:49 
QuestionMy First Java Pin
MallardsReach12-Mar-20 10:07
MallardsReach12-Mar-20 10:07 
AnswerRe: My First Java Pin
Richard MacCutchan12-Mar-20 23:23
mveRichard MacCutchan12-Mar-20 23:23 
GeneralRe: My First Java Pin
MallardsReach13-Mar-20 2:59
MallardsReach13-Mar-20 2:59 
Questionbooks examples of precedures stored for sqlserver Pin
Member 147683149-Mar-20 21:20
Member 147683149-Mar-20 21:20 
AnswerRe: books examples of precedures stored for sqlserver Pin
Richard MacCutchan9-Mar-20 22:25
mveRichard MacCutchan9-Mar-20 22:25 
AnswerRe: books examples of precedures stored for sqlserver Pin
ZurdoDev12-Mar-20 11:03
professionalZurdoDev12-Mar-20 11:03 
QuestionPLEASE HELP JAVA Pin
Member 147599401-Mar-20 14:19
Member 147599401-Mar-20 14:19 
Question: Write a Java program for a 2-dice game. This game will roll the two dice together for 100 times. In each time, it will display the face values from both dice. The program will count how many times (out of these 100 attempts) did the two dice generate a total point of 10 or above, and display the result at the end. (10 pts) See the execution example above.
Requirements:
a) In this question, use the Random class and its object to simulate dice rolling. Make sure your dice will generate integer values in the range of 1 - 6.
b) You will need two counter variables. One is to count for how many attempts you have rolled the two dice – to control the loop. The other is to count how many times that your two dices gave a total point of 10 or above.
c) Use a WHILE loops in this program. DO NOT USE THE OTHER LOOP METHODS in this question.
d) Your class should be named TwoDiceGame, and your source code file should be named TwoDiceGame.java.
e) Programming styles are always required.


My code:
import java.util.Random;


public class TwoDiceGame {
public static void main(String[] args){

// Declare a counter variable to count the loop time
int count = 0;

int die1, die2;

for(int i=0;i<100;i++)

rNums = new Random(); // create a new object of Random class


int die1 = rNums.nextInt(6)+1;
int die2= rNums.nextInt(6)+1;


if(Die1 + Die2 >= 10);
count ++;

}

System.out.println ("Out of 100 rolls of the two dice, the total of both the dice greater than or equal to 10 was %d times");
}
{
}

Errors:

----jGRASP exec: javac -g TwoDiceGame.java
TwoDiceGame.java:32: error: <identifier> expected
    System.out.println ("Out of 100 rolls of the two dice, the total of both the dice greater than or equal to 10 was %d times");
                      ^
TwoDiceGame.java:32: error: illegal start of type
    System.out.println ("Out of 100 rolls of the two dice, the total of both the dice greater than or equal to 10 was %d times");
                        ^
TwoDiceGame.java:34: error: class, interface, or enum expected
       {
       ^
3 errors

 ----jGRASP wedge: exit code for process is 1.
 ----jGRASP: operation complete.



Can someone please help me revise this code? I have this due by tonight and have tried everything to fix it.
AnswerRe: PLEASE HELP JAVA Pin
Richard MacCutchan1-Mar-20 21:36
mveRichard MacCutchan1-Mar-20 21:36 
AnswerRe: PLEASE HELP JAVA Pin
Richard MacCutchan1-Mar-20 21:42
mveRichard MacCutchan1-Mar-20 21:42 
GeneralRe: PLEASE HELP JAVA Pin
Member 1477360615-Mar-20 10:11
Member 1477360615-Mar-20 10:11 
GeneralRe: PLEASE HELP JAVA Pin
Richard MacCutchan15-Mar-20 12:26
mveRichard MacCutchan15-Mar-20 12:26 
AnswerRe: PLEASE HELP JAVA Pin
MallardsReach13-Mar-20 3:12
MallardsReach13-Mar-20 3:12 
GeneralRe: PLEASE HELP JAVA Pin
Richard MacCutchan13-Mar-20 4:30
mveRichard MacCutchan13-Mar-20 4:30 
GeneralRe: PLEASE HELP JAVA Pin
MallardsReach13-Mar-20 6:33
MallardsReach13-Mar-20 6:33 
GeneralRe: PLEASE HELP JAVA Pin
Richard MacCutchan13-Mar-20 6:49
mveRichard MacCutchan13-Mar-20 6:49 
GeneralRe: PLEASE HELP JAVA Pin
MallardsReach13-Mar-20 7:15
MallardsReach13-Mar-20 7:15 
QuestionTransfer data from SQL database to populate spinner Pin
Member 1475169121-Feb-20 5:55
Member 1475169121-Feb-20 5:55 
AnswerRe: Transfer data from SQL database to populate spinner Pin
Richard MacCutchan21-Feb-20 6:10
mveRichard MacCutchan21-Feb-20 6:10 
GeneralRe: Transfer data from SQL database to populate spinner Pin
Member 1475169121-Feb-20 7:38
Member 1475169121-Feb-20 7:38 
GeneralRe: Transfer data from SQL database to populate spinner Pin
Richard MacCutchan21-Feb-20 22:08
mveRichard MacCutchan21-Feb-20 22:08 
GeneralRe: Transfer data from SQL database to populate spinner Pin
Member 1475169122-Feb-20 14:38
Member 1475169122-Feb-20 14:38 
QuestionJson Manager Project (Need Critique/Possible Tips) Pin
Member 147385357-Feb-20 16:20
Member 147385357-Feb-20 16:20 
AnswerRe: Json Manager Project (Need Critique/Possible Tips) Pin
Richard MacCutchan7-Feb-20 22:06
mveRichard MacCutchan7-Feb-20 22:06 
GeneralRe: Json Manager Project (Need Critique/Possible Tips) Pin
Member 147385358-Feb-20 3:56
Member 147385358-Feb-20 3:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.