Advertisement
Guest User

ex13

a guest
Sep 19th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import java.util.*;
  2. public class ok {
  3. public static void printLetters(String x) {
  4. int length = x.length();
  5. int i=0;
  6. String word2;
  7. for (i=0; i<length; ++i){
  8. Character spell = x.charAt(i);
  9. word2 = Character.toString(spell)+"-";
  10. if (i==length-1){
  11. word2=word2.substring(0,word2.length()-1);
  12. }
  13. System.out.print(word2);
  14. }
  15. }
  16. public static void main(String [] args){
  17. Scanner in=new Scanner(System.in);
  18. System.out.println("Enter a word: ");
  19. String word=in.next();
  20. printLetters(word);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement