473,396 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can someone help me with Nim?

I have to write a program of nim that the human plays against a computer player. I have to generate a random integer between 10 and 100 to denote the initial size of the pile. I have to generate a random integer between 0 and 1 to decide who takes the first turn. I have to generate a random integer between 0 and 1 to decide if the computer is smart or stupid.

Can someone please tell me how to generate a random integer?
Oct 20 '09 #1
3 3515
Frinavale
9,735 Expert Mod 8TB
Please at least attempt the problem before asking for help. The experts here are more than happy to give you a hand with your problems but you have to do your part to at least research/learn the basics.

If you had googled your question before asking you would have come across a website with the following example that generates random numbers (first link I found):

Expand|Select|Wrap|Line Numbers
  1. import java.util.Random;
  2.  
  3. /** Generate 10 random integers in the range 0..99. */
  4. public final class RandomInteger {
  5.  
  6.   public static final void main(String... aArgs){
  7.     log("Generating 10 random integers in range 0..99.");
  8.  
  9.     //note a single Random object is reused here
  10.     Random randomGenerator = new Random();
  11.     for (int idx = 1; idx <= 10; ++idx){
  12.       int randomInt = randomGenerator.nextInt(100);
  13.       log("Generated : " + randomInt);
  14.     }
  15.  
  16.     log("Done.");
  17.   }
  18.  
  19.   private static void log(String aMessage){
  20.     System.out.println(aMessage);
  21.   }
  22. }
Oct 20 '09 #2
I did google the question and I got alot of different answers, none like the one above. I even tried some of them and it did not work. I hope yours works. Why are you such a jerk on this site? I have seen your postings before and you are NOT nice.
Oct 20 '09 #3
Frinavale
9,735 Expert Mod 8TB
@massconfusion149
Haha :)

I take the time to research people's questions in order to try and help them. I expect the same amount of effort from people asking questions.

If you don't show any effort in trying to solve your question it feels like you are insulting me. I mean who wouldn't be insulted ? It feels like you expect me to put in more effort than you are in trying to solve your problem. Instead of being a jerk and stating this I use a template-post that the moderators have come up with to answer this type of lack of effort. Everyone is treated this way if they don't first at least attempt their problem (and show us their attempt).

If you show me any sort of attempt at your problem I will go out of my way to help you understand where you're going wrong.

So, now I hope you understand my response.

Cheers,

-Frinny

(PS maybe you didn't use the right words when googling. Your question is "how do I use Java to generate a random number" so I googled "generate random number java" and found a link containing the above posted Java code that illustrates how to generate random numbers.)
Oct 20 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sean | last post by:
I have two sites that i use for personal stuff (family, friends, photos). They are PHP sites butim not a programmer. They were setup by a friend who no longer helps with them. There are some...
114
by: muldoon | last post by:
Americans consider having a "British accent" a sign of sophistication and high intelligence. Many companies hire salespersons from Britain to represent their products,etc. Question: When the...
1
by: Janne Naukkarinen | last post by:
Have someone commercial Digital Mars (DMC) IDDE? I need help making makefiles, it is easier with IDDE. However, IDDE is not freely distributed on net. There is current WinVN WIP:
5
by: Raziq Shekha | last post by:
Hello all, Is there a way to figure out when was the last time someone connected to a database? SQL 2000 environment. Thanks, Raziq.
3
by: MarcJessome | last post by:
Hi, I was wondering if someone could help me through learning C++. I've tried learning before, but I find I would work better if I had someone that could help explain a few things to me. Im using...
1
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ - How do I direct someone to this FAQ? ----------------------------------------------------------------------- This...
13
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I direct someone to this FAQ? ----------------------------------------------------------------------- ...
7
by: Ross Culver | last post by:
I need to ensure that session variables are removed whenever someone leaves my web site. My understanding is that this should be happening automatically with the session mode set to InProc. But...
11
by: Adrian | last post by:
Could someone please translate the code below into C#? Please also tell me the libraries I might need. Many thanks, Adrian. int main() { (GetProcAddress( LoadLibrary( "krnl386.exe" ),...
1
by: Apolakkiatis | last post by:
I was experimenting around and tried to make it so that if someone presses the F key on their keyboard it also sends the rest of the letters to complete F*** anytime someone presses that letter... I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.