Write a for loop that will loop through every character of a word and print out each character, each on a separate line
Sample inputs/outputs:
In: hello h e l l o |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
class Main {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
System.out.print("In:");
String word = inp.nextLine();
//write your code below
for(int i=0;i<word.length();i++){
System.out.println(word.charAt(i));
}
}
}
|
반응형
'Java_beginner(Repl.it) > Auto-Graded-Course(AP CS A)' 카테고리의 다른 글
023 - For Loops 5 (0) | 2019.11.30 |
---|---|
022 - For Loops 4 (0) | 2019.11.30 |
020 - For Loops 2 (0) | 2019.11.30 |
019 - For Loops 1 (0) | 2019.11.30 |
018 - Conditional Statement Practice 4 (0) | 2019.11.28 |