-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion96_RepeatSeperator.java
More file actions
59 lines (40 loc) · 1.08 KB
/
Question96_RepeatSeperator.java
File metadata and controls
59 lines (40 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package week6_String;
import java.util.Scanner;
public class Question96_RepeatSeperator {
public static void main(String[] args) {
// olcay // Jul 8, 2020
/* Given two strings, word and a separator sep,
return a big string made of count occurrences of the word, separated by the separator string.
Example:
input: Word
input: X
input: 3
output: WordXWordXWord
Example:
input: This
input: And
input: 2
output: ThisAndThis
Example:
input: This
input: And
input: 1
output: This
*/
Scanner scan = new Scanner(System.in);
System.out.println("Enter String , seperator and a number: ");
String word = scan.next();
String separator = scan.next();
int count = scan.nextInt();
int count1=0;
boolean flag=false;
do {
if(flag) {
System.out.print(separator);
}
System.out.print(word);
count1++;
flag = true;
}while(count1<count);
}
}