Results 1 to 2 of 2
  1. #1
    lowpro is offline Member
    Join Date
    Nov 2007
    Location
    boston
    Posts
    10
    Rep Power
    0

    Angry 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

  2. #2
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    9

    Default

    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.
    Java 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.

Similar Threads

  1. digital sign libraries
    By Shuru in forum Advanced Java
    Replies: 4
    Last Post: 11-07-2008, 09:01 AM
  2. Help please in digital clock
    By jaidod in forum Java Applets
    Replies: 1
    Last Post: 04-17-2008, 05:05 PM
  3. random numbers without random class`
    By carlos123 in forum New To Java
    Replies: 4
    Last Post: 01-17-2008, 11:44 PM
  4. need help print char and digital
    By lowpro in forum New To Java
    Replies: 4
    Last Post: 12-04-2007, 08:20 AM
  5. Print A Pdf
    By Jack in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 06:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •