Since I'm a Java Novice, I need some help writing a program (not sure why I come up as an expert; I'm not)

I have to write a program that has a class dice that produces a random integer with a value of 1 to 6 (inclusive).  I need to write another class throw that gets two random numbers from class dice and adds them together.  Then I have to write a class count that counts the number of times each total appears and stores the result in an array.  Finally, I must write a class output that displays the results, showing the total (2 through 12) and the number of times it appeared in 1000 throws.

My initial code for the first part of my problem follows.  Is this right?  Do I import java.lang?  
 
Public class Dice {  
     private  RandomGenerator  rgen = RandomGenerator.getInstance();
     int die = rgen.nextInt(1, 6)
     println(Rolling dice:  + die + );
            return total;
}

Open in new window

calbanese13Asked:
Who is Participating?
 
Thomas4019Connect With a Mentor Commented:
In java you never need to import "java.lang.*" That is imported automatically.

Java is a case-sensitive language, the keyword "public" should be all lower case whenever you use it.

The class "RandomGenerator" is not part of the Standard Java programming language. Is it part of an extension you are using. I dont know if that code is right without knowing where that class is from.

In java, there are no globals, everything is in a class. You cannot just say println(). You need to use System.out.println("Some String"). Also, whenever you have a String literal in java, it must be enclosed in quotes. Your line 6 should look something like System.out.println("Rolling dice: " + die);

As for the rest of the project. I can only help you with specific problems or questions.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.