Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-09-2007, 07:26 AM
Member
 
Join Date: Nov 2007
Location: boston
Posts: 10
lowpro is on a distinguished road
need help print random digital
public class randm
{

// have problem print rndn # from 0 to 9 ten by ten. thnks adv/////
public static void main(String[] args) {
int row = 10 ;
int colum = 10;
char a = 'a', z = 'z';

System.out.printf("a = %s/%d z = %s/%d " +
"'0' = %s/%d '9' = %s/%d%n",
a, (int)a, z, (int)z,
'0', (int)'0', '9', (int)'9');
System.out.println("RandomCharacter: ");
System.out.println("limit is :" + row+ " BY" +" "+ colum+ "\n");



for(int i = 0; i < 10; ++i){

for(int j = 0; j < 10; ++j)
{
char ch = getRandomCharacter(a , z);

System.out.print(ch +",");

}// end innerLoop

System.out.println();

}// end outer forLoop



System.out.println("\nRandomDigitalCharacter: ");
System.out.println("limit is :" + row+ " BY " + " " + colum +"\n");

///// somewhere here i have problem printing rand # from 0 to 9 please help/////

for(int i = 0; i < 10; ++i){ // how many line

for(int j = 0; j < 10; ++j) // how time perLine
{


int num = (int)getRandomDigitalCharacter();

System.out.print(num+",");

}// end innerLoop

System.out.println();

}// end outer forLoop





}// end main

public static char getRandomCharacter(char ch1, char ch2){
return (char) (ch1 + Math.random() * (ch2 - ch1 + 1));

} // end getRandChart

public static char getRandomDigitalCharacter(){
return getRandomCharacter('0' ,'9');

}// end getRandmD

}// end class
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-31-2007, 08:47 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
I'm not sure what exactly your problem is. Some things to keep in mind when posting:
1) Use proper English when posting, abbreviations only restrict those who are trying to assist you.
2) State your problem specifically.
3) Any error messages you're receiving.
4) What your desired outcome is.
5) Use code tags when posting code.

If your problem is outputting a random number between 0 and 9, that's easy and judging by your code, I find it hard to believe you don't know this.
Code:
double num = Math.random() * 10; System.out.println((int)num);
Then again, I'm probably misinterpreting what your problem is, please follow the rules(of many-see the FAQ) listed above.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
digital sign libraries Shuru Advanced Java 4 11-07-2008 10:01 AM
Help please in digital clock jaidod Java Applets 1 04-17-2008 06:05 PM
random numbers without random class` carlos123 New To Java 4 01-18-2008 12:44 AM
need help print char and digital lowpro New To Java 4 12-04-2007 09:20 AM
Print A Pdf Jack Advanced Java 2 07-02-2007 07:40 AM


All times are GMT +3. The time now is 04:05 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org