Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class ok {
- public static void printLetters(String x) {
- int length = x.length();
- int i=0;
- String word2;
- for (i=0; i<length; ++i){
- Character spell = x.charAt(i);
- word2 = Character.toString(spell)+"-";
- if (i==length-1){
- word2=word2.substring(0,word2.length()-1);
- }
- System.out.print(word2);
- }
- }
- public static void main(String [] args){
- Scanner in=new Scanner(System.in);
- System.out.println("Enter a word: ");
- String word=in.next();
- printLetters(word);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement