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

    Angry need help print char and digital

    //:mad: i need help print 100 char and 100 num tem per line.i try try but no success.thks in adv

    public class C5E23{
    public static void main(String[] args){

    int num;

    for(char s = 0; s < 100; ++s) {
    //for(int perLine = 0; perLine <= 10; ++perLine)
    char ch = getRandomCharacter(s);
    System.out.print(ch);
    }
    {
    for(int i = 0; i < 100; ++i)
    num = (int) getRandomDigital(i);
    System.out.print(num);
    }


    }//end main
    public static char getRandomCharacter(char ch1, char ch2){
    return (char) (ch1 + Math.randon() * (ch2 - ch1 + 1));
    }
    public static char getRandomDigitalCharacter(){

    return getRandomCharacter('0' , '9');
    }







    }//end class

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    Java Code:
        public static void main(String[] args) {
            int limit = 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: ");
            for(char s = 0; s < limit; ++s) {
                char ch = getRandomCharacter(a, z);
                System.out.print(ch);
                if(s < limit-1)
                    System.out.print(", ");
            }
            System.out.println("\nRandomDigitalCharacter: ");
            for(int i = 0; i < limit; ++i) {
                int num = (int) getRandomDigitalCharacter();
                System.out.print(num);
                if(i < limit-1)
                    System.out.print(", ");
            }
        }
    
        public static char getRandomCharacter(char ch1, char ch2){
            return (char) (ch1 + Math.random() * (ch2 - ch1 + 1));
        }
    
        public static char getRandomDigitalCharacter(){
            return getRandomCharacter('0' , '9');
        }

  3. #3
    lowpro is offline Member
    Join Date
    Nov 2007
    Location
    boston
    Posts
    10
    Rep Power
    0

    Default

    thnks Hardwire for big help.the program is printing rite but i think it was suppost to print ten line of tem which will be hundred of num and hundred of char.also wht are those: a = a/97 z = z/122 '0' = 0/48 '9' = 9/97

    thnks in adv

  4. #4
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    also wht are those: a = a/97
    char value / char value cast to an int value
    Just to see what you're working with.

  5. #5
    lowpro is offline Member
    Join Date
    Nov 2007
    Location
    boston
    Posts
    10
    Rep Power
    0

    Default

    thnks for help
    Last edited by lowpro; 12-04-2007 at 03:54 PM. Reason: more info

Similar Threads

  1. digital sign libraries
    By Shuru in forum Advanced Java
    Replies: 4
    Last Post: 11-07-2008, 08:01 AM
  2. Help please in digital clock
    By jaidod in forum Java Applets
    Replies: 1
    Last Post: 04-17-2008, 04:05 PM
  3. Casting an int value into a char
    By kurtulas in forum New To Java
    Replies: 2
    Last Post: 02-16-2008, 08:03 PM
  4. need help print random digital
    By lowpro in forum New To Java
    Replies: 1
    Last Post: 12-31-2007, 06:47 AM
  5. Help with, String, Char
    By lenny in forum New To Java
    Replies: 1
    Last Post: 07-25-2007, 02:58 PM

Posting Permissions

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