Page 1 of 2 12 LastLast
Results 1 to 20 of 24
  1. #1
    blacksky is offline Member
    Join Date
    Jan 2009
    Posts
    8
    Rep Power
    0

    Default How to print chars with symbols from a string

    Hello!

    Just before I write my problem I would like to wish you all a happy new year!

    I'm a student who is still fresh to programing in java. I have to make a program which will read a string of text and then print it out with chars made with symbols (*).

    So a person can enter some chars and it should look something like this:
    (EDIT: cant post images)
    (EDIT 2: the char under didnt come out too good. just look on google "ascii generator" and thats something what im supposed to do)

    **
    ****
    ** **
    ******
    ** **

    this above is char a. It has to be for every letter. Since we have some special letters we can type the "č" as "c", "š" as "s" and "ž" as "z".

    The string should also break line at about 80th column and resume printing in a new line.


    This is what I have come up with so far. I haven't done it all yet, i know. but I have tested it for only the char "a" and it writes "A" under the first "A". I know this is because i used "\n" but the problem is that I don't know how else I would print those chars with symbols. Is there some other way to remain in the first line after printing the first char out? Like move the cursor back up to the first line? Or should I type those chars with symbols in soem other way.

    Java Code:
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    
    public class Test_input {
    
    	public static void main(String[] args) {
    		
    		try {
    		System.out.print("Enter text here: ");
    		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    		String text = br.readLine();
    		
    		// this is for the string length
    		int length_of_text = text.length();
    		
    		// the counter is used for printing, it prints as long as i have a char to print out
    		int counter = -1;
    		
    		char a = 'a';
    		char b = 'b';
    		char c = 'c';
    		char č = 'č';
    		char d = 'd';
    		char e = 'e';
    		char f = 'f';
    		char g = 'g';
    		char h = 'h';
    		char i = 'i';
    		char j = 'j';
    		char k = 'k';
    		char l = 'l';
    		char m = 'm';
    		char n = 'n';
    		char o = 'o';
    		char p = 'p';
    		char r = 'r';
    		char s = 's';
    		char š = 'š';
    		char t = 't';
    		char u = 'u';
    		char v = 'v';
    		char z = 'z';
    		char ž = 'ž';
    		char x = ' ';
    		
    		
    		while (counter < length_of_text) {
    				counter += 1;
    				
    				if (text.charAt(counter) == a)
    					System.out.print("  **  \n" + 
    									 " **** \n" + 
    									 "**  **\n" +
    									 "******\n" +
    									 "**  **\n");
    			
    				else if (text.charAt(counter) == b)
    					System.out.print("B");
    				else if (text.charAt(counter) == c)
    					System.out.print("C");
    				else if (text.charAt(counter) == č)
    					System.out.print("C");
    				else if (text.charAt(counter) == d)
    					System.out.print("D");
    				else if (text.charAt(counter) == e)
    					System.out.print("E");
    				else if (text.charAt(counter) == f)
    					System.out.print("F");
    				else if (text.charAt(counter) == g)
    					System.out.print("G");
    				else if (text.charAt(counter) == h)
    					System.out.print("H");
    				else if (text.charAt(counter) == i)
    					System.out.print("I");
    				else if (text.charAt(counter) == j)
    					System.out.print("J");
    				else if (text.charAt(counter) == k)
    					System.out.print("K");
    				else if (text.charAt(counter) == l)
    					System.out.print("L");
    				else if (text.charAt(counter) == m)
    					System.out.print("M");
    				else if (text.charAt(counter) == n)
    					System.out.print("N");
    				else if (text.charAt(counter) == o)
    					System.out.print("O");
    				else if (text.charAt(counter) == p)
    					System.out.print("P");
    				else if (text.charAt(counter) == r)
    					System.out.print("R");
    				else if (text.charAt(counter) == s)
    					System.out.print("S");
    				else if (text.charAt(counter) == š)
    					System.out.print("S");
    				else if (text.charAt(counter) == t)
    					System.out.print("T");
    				else if (text.charAt(counter) == u)
    					System.out.print("U");
    				else if (text.charAt(counter) == v)
    					System.out.print("V");
    				else if (text.charAt(counter) == z)
    					System.out.print("Z");
    				else if (text.charAt(counter) == ž)
    					System.out.print("Z");
    				else if (text.charAt(counter) == x)
    					System.out.print(" ");
    				
    		}
    		
    		}	catch (Exception e) {
    		}
    	}
    
    }
    Sorry for my English, I know its not the best. Thanks in advance for all of your help.

    EDIT 3: converted everything to english
    Last edited by blacksky; 01-04-2009 at 03:59 PM.

  2. #2
    Join Date
    Dec 2008
    Location
    Italy
    Posts
    79
    Rep Power
    0

    Default

    1st suggestion: You'd better changing your member names in English, it makes code easier to read for us. And mixing languages is not a good practice anyway.

    I think your problem is quite tricky, but keep in mind that with the println() or print() methods your cursor writes a line and you can't get back. So the only solution, if you want to use those methods, is buffering the characters and writing the whole line at a time.

    For example, you know that the first line must contain the chars 'a', 'b', and 'c'. Then you write the first line for the symbols a, b, c, then the second line, etc...

    The algorythm is quite complicated. Now I'm trying to find a decent one

  3. #3
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default

    I'm assuming you want something like:
    Java Code:
      ****     *****
     **   **   **  **
     ******    ****
     **   **   **  **
     **   **   *****
    There are various print methods. The one you are using is println() method which moves the cursor to the next line. You can use the print() method which just prints, without the CRLF (Carriage Return Line Feed). I'm not sure that this will solve your problem, because your trying to print varoius lines of characters to the screen, not just one character.

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  4. #4
    blacksky is offline Member
    Join Date
    Jan 2009
    Posts
    8
    Rep Power
    0

    Default

    @raffaele181188:
    I have converted everything to English as you have suggested. Sorry I forgot to do it when I posted the code here.

    @CJSLMA:

    Yes the thing you have posted is exactly what I want to print out. And I'm not using println(). I'm using print ().
    Thats the biggest problem. I'm trying to print all the chars in one line. And brake after 80 column (this part is not the problem, i figure i would just count the fixed length of every char and break after 80).
    Last edited by blacksky; 01-04-2009 at 04:04 PM.

  5. #5
    Join Date
    Dec 2008
    Location
    Italy
    Posts
    79
    Rep Power
    0

    Default

    My solution
    Java Code:
    //The ABSTRACT class symbol represent your graphic
    //character. There is a private class called Symbol<X>
    //for each character you'll want to implement
    //All these classes extend Symbol and define its getSymbols()
    //The returned value is used in the main application
    
    abstract class Symbol {
       //For example
       public static final int HEIGHT = 5;
    
       abstract String[] getSymbols();
    
       //This is a factory method to instantiate a Symbol
       public static Symbol makeMeA(char request) {
          //...
       }
    
       //This is the private class which represents the letter 'A'
       private class SymbolA extends Symbol {
          String[] getSymbols() {
             String[] output = new String[] {
                  "      *      ",
                  "    *   *   ",
                  "  *       * ",
                  " *******",
                  " *         *",
             };//All lines are same length ^^^
             return output;
          }
       }
    
       private class SymbolB extends Symbol { ... }
       ...
       private class SymbolZ extends Symbol { ... }
    }
    Then you have the main class
    Java Code:
    public class OutSymbols {
       public static void main(String... args) {
           //... First you get your String and then cut it off in Symbols
           //objects, putting them in a container. Then
           for (int i = 0; i < Symbol.HEIGHT; i++) {
               for (Symbol in your line to be output) {
                   String[] graphics = symbol.getSymbols();
                   System.out.print(graphics[i]);
               }
           }
       }
    }
    I hope my code is sufficiently clear to be understood. Of course, you have to tune it, it's only pseudo code
    Last edited by raffaele181188; 01-04-2009 at 04:56 PM.

  6. #6
    blacksky is offline Member
    Join Date
    Jan 2009
    Posts
    8
    Rep Power
    0

    Default

    Thank you very much for this, but unfortunately it is a bit too advanced for me. The problem is that I will have to show my program and explain every single line of code. Since I'm am still new to java and programing in general I don't understand a lot of things in your code.

    If there was just a way to print the chars without those "\n" which break the line, but print a char as a whole and then resume at the first line. That would make it alot easier I guess.

    Still looking for other suggestions. Thank you guys for all your effort so far :).

  7. #7
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default hhhmmm...

    Can you use Arrays? Not sure this will work...
    Create your letter using Arrays (see the sample that raffaele posted) and you would have to print them like a dot matrix printer (first row 0, then row 1, etc)...
    For example:
    print row 0:
    print(letterA[0] + " " + letterB[0]);
    Java Code:
      ****     *****
    print row 1:
    print(letterA[1] + " " + letterB[1]);
    Java Code:
      ****     *****
     **   **   **  **
    print row 2:
    print(letterA[2] + " " + letterB[2]);
    Java Code:
      ****     *****
     **   **   **  **
     ******    ****
    etc...

    There will probably be more considerations to handle with this... just an idea.

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  8. #8
    Join Date
    Dec 2008
    Location
    Italy
    Posts
    79
    Rep Power
    0

    Default

    The CJLSMAN's solution works perfectly, and is a bit simpler then my code. But this eventually need to be wrapped into some usable class, and so you come back to my code...
    Both CJLSMAN and I think that the only solution you have is to print one line at a time. If you can use my code then you'll save a lot of time.

    Anyway, in Java there is no way to output a char at a given (x, y)

    All you can do is calling print() or println(), which behave the same except for the adding of '\n' at the end of the ouput. You can't get back, sorry :)

  9. #9
    Join Date
    Dec 2008
    Location
    Italy
    Posts
    79
    Rep Power
    0

    Default

    I continued the CJLSMAN's idea, but this is neither OO nor reusable code. It's quite basic. Inside your class declaration you define these fields:
    Java Code:
    //This is a String array, made up by the lines which constitute
    //your gliph. Keep in mind that all of String objects 
    //_ARE_THE_SAME_LENGTH_ 
    private static String[] letterA = {
    "****",
    "*   *",
    "****",
    "*    *",
    }
    
    private static String[] letterB = {
    ...
    }
    
    ...
    
    private static String[] letterZ = { ...}
    Then in your main method, once you have got the chars in your line
    Java Code:
    //This array contains the letters which will be ouput
    //Something like
    String[][] line = { letterH, letterE, letterL, letterL, letterO};
    //The above contains the letters H E L L O
    
    //Now for loop
    //Of course this is an example. Your numOfRows will be
    //letterA.length or letterB.length or ...
    int numOfRows = 5;
    for (int row = 0; row < numOfRows; row++) {
       for (String[] gliph : line) {
          System.out.print(gliph[row]);
       }
       System.out.println();
    }
    Last edited by raffaele181188; 01-04-2009 at 08:14 PM. Reason: coding errors, eh eh

  10. #10
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Same code...

    Yeap... I basically came to the same code as you did raffaele. Definitely not kosher, but it works.

    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  11. #11
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default afterthought...

    Thinking a little more about this, if a letter is specified that isn't represented by your code you can always have the code default to a generic symbol say like a splat "*".

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  12. #12
    Join Date
    Dec 2008
    Location
    Italy
    Posts
    79
    Rep Power
    0

    Default

    Quote Originally Posted by CJLSMAN
    I basically came to the same code as you did
    No no... :) the code is yours all! ;)
    My solution was totally different, then I saw the yours, I found it interesting and coded on your idea eh eh. A lil curiosity: what does your name mean?

    @blacksky
    Now it's up to you getting the letters and splitting the lines... And keep in mind: THAT isn't OO approach. It may seems C code...

  13. #13
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default The Man Show...

    My code differed in that:
    • The user can input his code (using a JOptionPane, but command line arguments would have worked the same)
    • I used an ArrayList that contained the letter arrays (since I don't know how many letters the user is going to specify)
    • I placed the letter arrays in methods (call a method, get a string array back).

    I'll post my solution once the BlackSky posts his solution.

    As for my nick, it's the initials of all my name + "man". Sorta like Superman, Ultraman, etc.:)

    @blacksky: remember... when creating the letters, they have to have the same amount of rows.

    Luck
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  14. #14
    Join Date
    Dec 2008
    Location
    Italy
    Posts
    79
    Rep Power
    0

    Default

    @CJLS-man eh eh
    Ok, I understood you. I only think that he doesn't know ArrayLists and JOptionPanes :p

  15. #15
    blacksky is offline Member
    Join Date
    Jan 2009
    Posts
    8
    Rep Power
    0

    Default

    Yes your right I don't fully understand. I know a bit about ArrayLists. How to add a char to an array or some other value and maybe how to sort the list but that is about it.

    I understand what you meant by printing one line after another but I don't know how to implement that since it has to print random chars which he breaks from the string which a user inputs (ex: hello world).

    I have tryed another thing. I have used a function which I have found on the net. It reads the chars from text files (.txt) and prints them line by line. The problem yet again is that it prints every char line by line (since every letter char has its own .txt file). And because of that every next letter is printed under the last one. Again same problem.
    The changed code:

    Java Code:
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    
    public class Test_input {
    
    	public static void main(String[] args) {
    		
    		try {
    		System.out.print("Enter text here: ");
    		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    		String text = br.readLine();
    		
    		int length_of_text = text.length();
    		
    		int counter = -1;
    		
    		char a = 'a';
    		char b = 'b';
    		char c = 'c';
    		char č = 'č';
    		char d = 'd';
    		char e = 'e';
    		char f = 'f';
    		char g = 'g';
    		char h = 'h';
    		char i = 'i';
    		char j = 'j';
    		char k = 'k';
    		char l = 'l';
    		char m = 'm';
    		char n = 'n';
    		char o = 'o';
    		char p = 'p';
    		char r = 'r';
    		char s = 's';
    		char š = 'š';
    		char t = 't';
    		char u = 'u';
    		char v = 'v';
    		char z = 'z';
    		char ž = 'ž';
    		char x = ' ';
    		
    		
    		while (counter < length_of_text) {
    				counter += 1;
    				
    				if (text.charAt(counter) == a){
    					File file = new File("a.txt");
    		        	String keks = Readfromtext(file);
    		        	System.out.print(keks);
    		        	}
    			
    				else if (text.charAt(counter) == b)
    					System.out.print("B");
    				else if (text.charAt(counter) == c)
    					System.out.print("C");
    				else if (text.charAt(counter) == č)
    					System.out.print("C");
    				else if (text.charAt(counter) == d)
    					System.out.print("D");
    				else if (text.charAt(counter) == e)
    					System.out.print("E");
    				else if (text.charAt(counter) == f)
    					System.out.print("F");
    				else if (text.charAt(counter) == g)
    					System.out.print("G");
    				else if (text.charAt(counter) == h)
    					System.out.print("H");
    				else if (text.charAt(counter) == i)
    					System.out.print("I");
    				else if (text.charAt(counter) == j)
    					System.out.print("J");
    				else if (text.charAt(counter) == k)
    					System.out.print("K");
    				else if (text.charAt(counter) == l)
    					System.out.print("L");
    				else if (text.charAt(counter) == m)
    					System.out.print("M");
    				else if (text.charAt(counter) == n)
    					System.out.print("N");
    				else if (text.charAt(counter) == o)
    					System.out.print("O");
    				else if (text.charAt(counter) == p)
    					System.out.print("P");
    				else if (text.charAt(counter) == r)
    					System.out.print("R");
    				else if (text.charAt(counter) == s)
    					System.out.print("S");
    				else if (text.charAt(counter) == š)
    					System.out.print("S");
    				else if (text.charAt(counter) == t)
    					System.out.print("T");
    				else if (text.charAt(counter) == u)
    					System.out.print("U");
    				else if (text.charAt(counter) == v)
    					System.out.print("V");
    				else if (text.charAt(counter) == z)
    					System.out.print("Z");
    				else if (text.charAt(counter) == ž)
    					System.out.print("Z");
    				else if (text.charAt(counter) == x)
    					System.out.print(" ");
    				
    		}
    		
    		}	catch (Exception e) {
    		}
    	}
    
    public static String Readfromtext (File file){
    	
    	
    	StringBuffer contents = new StringBuffer();
        BufferedReader reader = null;
        try
        {
            reader = new BufferedReader(new FileReader(file));
            String text = null;
    
            // repeat until all lines is read
            while ((text = reader.readLine()) != null)
            {
               contents.append(text)
                    .append(System.getProperty(
                        "line.separator"));
            }
        } catch (FileNotFoundException e)
        {
            e.printStackTrace();
        } catch (IOException e)
        {
            e.printStackTrace();
        } finally
        {
            try
            {
                if (reader != null)
                {
                    reader.close();
                }
            } catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        
        // show file contents here
        return contents.toString();
    	
    }
    
    }
    It is a bit frustrating trying to find the right answer.

    EDIT: Again I have only tryed it for letter A. So if i input "aa" it prints out one a under the last one.
    Like this:

    Java Code:
    Enter text here: aa
      **  
     **** 
    **  **
    ******
    **  **
    **  **
      **  
     **** 
    **  **
    ******
    **  **
    **  **
    Last edited by blacksky; 01-04-2009 at 11:16 PM.

  16. #16
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Some comments...

    Getting code from the web is great if you understand how it works. In this case, it really doesn't do what you need it to do. I would suggest trying to understand rafaele's posted code (second one). Basically, what it does is:
    • create a 2 dimension array (an array that contains arrays)
    • Create the letter arrays (tedious chore)
    • create a double nested "for" loop:
    • outer loop is go through the letter's rows
    • inner loop is to go throught the selected letter arrays
    • print the string of the current row of the current array (don't use println here)
    • between the 2 loops insert a println (so the new row can start at the left)


  17. If your interested in arraylists, I can help you with that... I'm no expert, but I know enough to be dangerious.

    Luck,
    CJSL


    does do what
Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
Reply With Quote Reply With Quote

  • #17
    blacksky is offline Member
    Join Date
    Jan 2009
    Posts
    8
    Rep Power
    0

    Default

    Thank you guys very much. I have partially solved the problem by using your idea and part of the code :). I have managed to print it out line by line (print the first line of every letter, then the second one, etc.). Unfortunatlly I still don't know how to break line (make space) for instance after the 80th column, then in the next line break it agian after 80th column and so on.

    The text prints out like this:
    Java Code:
    AAAAAAAAAAAA
    I would liek it to look like this:

    Java Code:
    AAAAAA
    // space
    AAAAAA
    How the code looks now:

    Java Code:
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    
    public class Test_input {
    
    	public static void main(String[] args) {
    		
    		try {
    		System.out.print("Vnesite besedilo: ");
    		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    		String input_text = br.readLine();
    		
    		String lowercase_text = input_text.toLowerCase();
    		
    		int length_of_text = lowercase_text.length();
    		length_of_text -= 1;
    		
    		char a = 'a';
    		char b = 'b';
    		char c = 'c';
    		char č = 'č';
    		char d = 'd';
    		char e = 'e';
    		char f = 'f';
    		char g = 'g';
    		char h = 'h';
    		char i = 'i';
    		char j = 'j';
    		char k = 'k';
    		char l = 'l';
    		char m = 'm';
    		char n = 'n';
    		char o = 'o';
    		char p = 'p';
    		char r = 'r';
    		char s = 's';
    		char š = 'š';
    		char t = 't';
    		char u = 'u';
    		char v = 'v';
    		char z = 'z';
    		char ž = 'ž';
    		char x = ' ';
    		
    		int heigth;
    		int counter;
    		
    		for (heigth = 0; heigth <= 4; heigth++){
    			
    		for (counter = 0; counter <= length_of_text; counter++){
    		
    				if (lowercase_text.charAt(counter) == a){
    					String crkaA[] = {  "  **   ",
    										" ****  ",
    										"**  ** ",
    										"****** ",
    										"**  ** "};
    					System.out.print(crkaA[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == b){
    					String crkaB[] = {  "****  ",
    										"**  * ",
    										"****  ",
    										"**  * ",
    										"***** "};
    					System.out.print(crkaB[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == c || lowercase_text.charAt(counter) == č){
    					String crkaC[] = {  " ****  ",
    										"**  ** ",
    										"**     ",
    										"**  ** ",
    										" ****  "};
    					System.out.print(crkaC[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == d){
    					String crkaD[] = {  "***    ",
    										"**  *  ",
    										"**   * ",
    										"**   * ",
    										"*****  "};
    					System.out.print(crkaD[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == e){
    					String crkaE[] = {  "***** ",
    										"**    ",
    										"***** ",
    										"**    ",
    										"***** "};
    					System.out.print(crkaE[heigth]);	
    				}
    				else if (lowercase_text.charAt(counter) == f){
    					String crkaF[] = {  "***** ",
    										"**    ",
    										"****  ",
    										"**    ",
    										"**    "};
    					System.out.print(crkaF[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == g){
    					String crkaG[] = {  " ****  ",
    										"**     ",
    										"**  ** ",
    										"**   * ",
    										" ****  "};
    					System.out.print(crkaG[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == h){
    					String crkaH[] = {  "**  ** ",
    										"**  ** ",
    										"****** ",
    										"**  ** ",
    										"**  ** "};
    					System.out.print(crkaH[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == i){
    					String crkaI[] = {  "*** ",
    										"*** ",
    										"*** ",
    										"*** ",
    										"*** "};
    					System.out.print(crkaI[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == j){
    					String crkaJ[] = {  "   ** ",
    										"   ** ",
    										"   ** ",
    										"*  ** ",
    										" ***  "};
    					System.out.print(crkaJ[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == k){
    					String crkaK[] = {  "**  * ",
    										"** *  ",
    										"***   ",
    										"** *  ",
    										"**  * "};
    					System.out.print(crkaK[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == l){
    					String crkaL[] = {  "**    ",
    										"**    ",
    										"**    ",
    										"**    ",
    										"***** "};
    					System.out.print(crkaL[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == m){
    					String crkaM[] = {  "**   ** ",
    										"* * * * ",
    										"*  *  * ",
    										"*     * ",
    										"*     * "};
    					System.out.print(crkaM[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == n){
    					String crkaN[] = {  "**  ** ",
    										"* * ** ",
    										"** * * ",
    										"**  ** ",
    										"**   * "};
    					System.out.print(crkaN[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == o){
    					String crkaO[] = {  " ****  ",
    										"**  ** ",
    										"**  ** ",
    										"**  ** ",
    										" ****  "};
    					System.out.print(crkaO[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == p){
    					String crkaP[] = {  "****  ",
    										"**  * ",
    										"****  ",
    										"**    ",
    										"**    "};
    					System.out.print(crkaP[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == r){
    					String crkaR[] = {  "****  ",
    										"**  * ",
    										"****  ",
    										"** *  ",
    										"**  * "};
    					System.out.print(crkaR[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == s || lowercase_text.charAt(counter) == š){
    					String crkaS[] = {  " ****  ",
    										"**     ",
    										" ****  ",
    										"    ** ",
    										" ****  "};
    					System.out.print(crkaS[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == t){
    					String crkaT[] = {  "****** ",
    										"  **   ",
    										"  **   ",
    										"  **   ",
    										"  **   "};
    					System.out.print(crkaT[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == u){
    					String crkaU[] = {  "**  ** ",
    										"**  ** ",
    										"**  ** ",
    										"**  ** ",
    										" ****  "};
    					System.out.print(crkaU[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == v){
    					String crkaV[] = {  "**   ** ",
    										"**   ** ",
    										"**   ** ",
    										" *   *  ",
    										"  ***   "};
    					System.out.print(crkaV[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == z || lowercase_text.charAt(counter) == ž){
    					String crkaS[] = {  "****** ",
    										"   **  ",
    										"  **   ",
    										" **    ",
    										"****** "};
    					System.out.print(crkaS[heigth]);
    				}
    				else if (lowercase_text.charAt(counter) == x){
    					String razmik[] = { "      ",
    										"      ",
    										"      ",
    										"      ",
    										"      "};
    					System.out.print(razmik[heigth]);
    				}	
    		}
    		System.out.println();
    		}
    		
    		}	catch (Exception e) {
    		}
    		
    	}
    
    
    
    }
    EDIT: Code translated to english again
    Last edited by blacksky; 01-05-2009 at 08:49 PM.

  • #18
    Join Date
    Dec 2008
    Location
    Italy
    Posts
    79
    Rep Power
    0

    Default

    Please, post the ouput of your program, so I'll be able to understand you. Also use the CODE tags

  • #19
    blacksky is offline Member
    Join Date
    Jan 2009
    Posts
    8
    Rep Power
    0

    Default

    This is what it looks like now.

    Output:
    Java Code:
    Enter text here: abcdefghijklmnop
      **   ****   ****  ***    ***** *****  ****  **  ** ***    ** **  * **    **   ** **  **  ****  ****  
     ****  **  * **  ** **  *  **    **    **     **  ** ***    ** ** *  **    * * * * * * ** **  ** **  * 
    **  ** ****  **     **   * ***** ****  **  ** ****** ***    ** ***   **    *  *  * ** * * **  ** ****  
    ****** **  * **  ** **   * **    **    **   * **  ** *** *  ** ** *  **    *     * **  ** **  ** **    
    **  ** *****  ****  *****  ***** **     ****  **  ** ***  ***  **  * ***** *     * **   *  ****  **
    I would like the code to print a line or tow of space (ex: "System.out.println()") after the bottom length of chars exced 80 columns.

    For instance if every char has a length of 8 chars (it doesn't in my code, i'm just giving an example) taht would mean I could type 10 chars in one line and after taht it woudl make a space and go into a new line.

    If you imagine that every of my chars above in the code has 8 chars, that means that char j (in a sequence "abcdefghijklmnop") is tenth and every other char after him goes into a new line.

    Example what i would want it to look like:
    Java Code:
    Enter text here: abcdefghijklmnop
      **   ****   ****  ***    ***** *****  ****  **  ** ***    **
     ****  **  * **  ** **  *  **    **    **     **  ** ***    **
    **  ** ****  **     **   * ***** ****  **  ** ****** ***    **
    ****** **  * **  ** **   * **    **    **   * **  ** *** *  **
    **  ** *****  ****  *****  ***** **     ****  **  ** ***  ***  
    
    
    **  * **    **   ** **  **  ****  **** 
    ** *  **    * * * * * * ** **  ** **  * 
    ***   **    *  *  * ** * * **  ** ****   
    ** *  **    *     * **  ** **  ** **  
    **  * ***** *     * **   *  ****  **
    ;)

  • #20
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Splitting letters

    How many letters fit in 80 columns? 8? 9? 10? Whatever the number, just print that many letters and than do a /n (CRLF), and print the next 8-10 characters, etc....

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  • Page 1 of 2 12 LastLast

    Similar Threads

    1. chars
      By whosadork in forum New To Java
      Replies: 6
      Last Post: 10-03-2008, 09:40 PM
    2. writting extended ascii chars on socket........or Endianness Issue......??
      By sachinj13 in forum Threads and Synchronization
      Replies: 8
      Last Post: 09-23-2008, 02:20 PM
    3. Can we append more than 255 chars to <a href>??
      By freddieMaize in forum Advanced Java
      Replies: 22
      Last Post: 07-18-2008, 04:04 PM
    4. Print the text file and print preview them
      By Java Tip in forum java.awt
      Replies: 0
      Last Post: 06-22-2008, 11:04 PM
    5. How to cut symbols from a string?
      By gutters in forum New To Java
      Replies: 3
      Last Post: 06-16-2008, 03:47 AM

    Posting Permissions

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