Repeat Letters java contains an incomplete program whose goa
Solution
Please find my program.
Please let me know in case of any issue.
import java.util.Scanner;
public class RepeatLetters{
// function defination
public static void repeatLetters(String text, int times){
// iterating through each character of test
for(int i=0; i<text.length(); i++){
// printing current letters
for(int j=1; j<=times; j++)
System.out.print(text.charAt(i));
}
System.out.println(\"\ \");
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String input = \"\";
int times;
while(true){
System.out.print(\"Enter some test, or q to quit: \");
input = sc.nextLine();
if(input.equals(\"q\"))
break; // stopping
System.out.print(\"Enter number of times (must be > 0): \");
times = sc.nextInt();
// calling functuion
repeatLetters(input, times);
}
}
}
/*
Sample output:
Enter some test, or q to quit: Hello
Enter number of times (must be > 0): 3
HHHeeellllllooo
Enter some test, or q to quit:q
*/

