Given the following inputs:
String s; |
Write a for loop that will print out each letter of the string s, separated by spaces, on the same line.
Sample input/outputs:
In: hello out: h e l l o
In: covert out: c o v e r t
In: blasphemy out: b l a s p h e m y |
Solution
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
class Bakjoon {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
System.out.print("In:");
String s = inp.nextLine();
//write your code below
for(int i=0;i<s.length();i++) {
System.out.print(s.charAt(i)+" ");
}
}
}
|
반응형
'Java_beginner(Repl.it) > Auto-Graded-Course(AP CS A)' 카테고리의 다른 글
031 - Further For Loop Practice 7 (mIxEd CaSe) (0) | 2019.12.07 |
---|---|
030 - Further For Loop Practice 6 (reverse string) (0) | 2019.12.07 |
028 - Further For Loop Practice 4 (repeating X times) (0) | 2019.12.07 |
027 - Further For Loop Practice 3 (descending) (0) | 2019.12.07 |
026 - Further For Loop Practice 2 (skipping by 3s) (0) | 2019.12.07 |