The Artima Developer Community
Sponsored Link

Java Answers Forum
Generate Number And Character

5 replies on 1 page. Most recent reply: Jun 3, 2002 2:16 AM by azri

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
Azrul Azhar

Posts: 9
Nickname: bllizard
Registered: Jun, 2002

Generate Number And Character Posted: Jun 2, 2002 9:13 PM
Reply to this message Reply
Advertisement
actually i'm new in java. i have a problem doing a task to perform number generation let say i want the out put to be like A001 to A999, B001 to B999 until Z001 to Z999. i hope somebody can help me on this problem. thanx


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Generate Number And Character Posted: Jun 2, 2002 10:46 PM
Reply to this message Reply
Wow, are you going to write a spreadsheet as your first java app?

Here is the quick 'n' dirty version:
class Numbers
{
   public static void main( String[] args )
   {
      for( char l = 'A'; l <= 'Z'; l++ )
         for( int i = 1; i < 1000; i++ )
            System.out.println( l + (i<100?i<10?"00":"0":"") + i );
   }
}


Maybe someone else will follow up with a more elegant rendition of the same thing...

Azrul Azhar

Posts: 9
Nickname: bllizard
Registered: Jun, 2002

Re: Generate Number And Character Posted: Jun 3, 2002 12:06 AM
Reply to this message Reply
thanx mate

azri

Posts: 2
Nickname: psych0vx
Registered: Jun, 2002

Re: Generate Number And Character Posted: Jun 3, 2002 1:18 AM
Reply to this message Reply
Seems like i have quite the same problem here..how to generate strings beginning with 0000,0001 then up to ZZZZ..i try to avoid using array...

Singh M.

Posts: 154
Nickname: ms
Registered: Mar, 2002

Re: Generate Number And Character Posted: Jun 3, 2002 1:42 AM
Reply to this message Reply
Seems like one of those "HOME WORK" problems... Be careful abt. plagiarism. Universities in Australia are pretty Strict abt. them.

azri

Posts: 2
Nickname: psych0vx
Registered: Jun, 2002

Re: Generate Number And Character Posted: Jun 3, 2002 2:16 AM
Reply to this message Reply
Thanks about the concern Mr.Singh. Dont have to worry, i'd already graduated. The code is needed to implement a system for the company i work for now.

Flat View: This topic has 5 replies on 1 page
Topic: Inheritance Previous Topic   Next Topic Topic: Where can I get the free develop tools of Java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use