DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Thread: help

  1. #1
    Join Date
    Oct 2003
    Posts
    21

    help

    i need help with this i dont really have a clue on what to really do but heres the question

    Write an application that, depending on the command-line input:
    reads several lines of text from the keyboard and encodes the text according to the following principle:
    - a becomes 1
    - b becomes 2
    - c becomes 3
    - ...
    - after each letter 0 is inserted
    - words are to be separated by '-'
    For example the string ``java programming'' should become:
    ``1001022010-16018070180101301309014070''

    Display the result of the encoding of the screen and write the result to file.

    reads in a file, supplied by the user, containing an encoding. The program should decode the file and display the result of this process on the screen.

    Nested if-statements will not be highly appreciated.question is finding a suitable algorithm for the encoding/decoding

  2. #2
    Join Date
    Jan 2004
    Posts
    20
    Hey there,

    Here's something i knocked up quickly to change "java" into "1001022010"
    Code:
        public static void main(String [] args) 
        {
            String str = new String("java");
            
            for(int i=0; i<str.length(); i++)
            {
                char character = str.charAt(i);
                int num = character;
                num = num - 96;
                System.out.print(num + "0");
            }
        }
    Is that all you need to get you started, or have you got some code already?

    Cheers, DJDaveMark

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links