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-03-2007, 11:20 AM
Member
 
Join Date: Nov 2007
Location: boston
Posts: 10
lowpro is on a distinguished road
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
Sponsored Links
  #2 (permalink)  
Old 12-03-2007, 08:08 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
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, 03:29 AM
Member
 
Join Date: Nov 2007
Location: boston
Posts: 10
lowpro is on a distinguished road
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, 03:38 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
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, 09:20 AM
Member
 
Join Date: Nov 2007
Location: boston
Posts: 10
lowpro is on a distinguished road
thnks for help

Last edited by lowpro : 12-04-2007 at 05:54 PM. Reason: more info
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
Casting an int value into a char kurtulas New To Java 2 02-16-2008 10:03 PM
need help print random digital lowpro New To Java 1 12-31-2007 08:47 AM
Help with, String, Char lenny New To Java 1 07-25-2007 04:58 PM


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


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