Given the following inputs:
int x; |
Write a for loop that will print out "AP CS A" x number of times, new line per print.
Sample input/outputs:
In: 3 AP CS A AP CS A AP CS A
In: 5 AP CS A AP CS A AP CS A AP CS A AP CS A
In: 1 AP CS A |
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:");
int x = inp.nextInt();
//write your code below
for(int i=0;i<x;i++) {
System.out.println("AP CS A");
}
}
}
|
반응형
'Java_beginner(Repl.it) > Auto-Graded-Course(AP CS A)' 카테고리의 다른 글
030 - Further For Loop Practice 6 (reverse string) (0) | 2019.12.07 |
---|---|
029 - Further For Loop Practice 5 (printing characters) (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 |
025 - Further For Loop Practice 1 (ascending) (0) | 2019.12.07 |