View Single Post
  #1 (permalink)  
Old 12-09-2007, 07:26 AM
lowpro lowpro is offline
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
Reply With Quote
Sponsored Links