How do I display a word diagonally in Java? -


i trying make program accepts word displays word diagonally. far i've gotten display vertically.

the scanner accepts "zip", outputs:

z     p   

how make go this:

z           p 

here code:

import java.util.scanner; public class exercise_4  {     public static void main(string [] args)     {         scanner scan = new scanner(system.in);          system.out.println("please enter words");          string word = scan.nextline();          (char ch: word.tochararray())         {             system.out.println(ch);         }     } } 

you can try this:-

   string s = "zip";     string spaces = "";      (int = 0; < s.length(); i++) {         system.out.println(spaces + s.charat(i));         spaces += "  ";     } 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -