Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-03-2007, 10:20 AM
Member
 
Join Date: Nov 2007
Location: boston
Posts: 10
Rep Power: 0
lowpro is on a distinguished road
Angry need help print char and digital
// 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
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 12-03-2007, 07:08 PM
hardwired's Avatar
Senior Member
 
Join Date: Jul 2007
Posts: 1,577
Rep Power: 4
hardwired is on a distinguished road
Default
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');
    }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-04-2007, 02:29 AM
Member
 
Join Date: Nov 2007
Location: boston
Posts: 10
Rep Power: 0
lowpro is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-04-2007, 02:38 AM
hardwired's Avatar
Senior Member
 
Join Date: Jul 2007
Posts: 1,577
Rep Power: 4
hardwired is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 12-04-2007, 08:20 AM
Member
 
Join Date: Nov 2007
Location: boston
Posts: 10
Rep Power: 0
lowpro is on a distinguished road
Default
thnks for help

Last edited by lowpro; 12-04-2007 at 04:54 PM. Reason: more info
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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 09:01 AM
Help please in digital clock jaidod Java Applets 1 04-17-2008 05:05 PM
Casting an int value into a char kurtulas New To Java 2 02-16-2008 09:03 PM
need help print random digital lowpro New To Java 1 12-31-2007 07:47 AM
Help with, String, Char lenny New To Java 1 07-25-2007 03:58 PM


All times are GMT +2. The time now is 07:01 AM.



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