Repeat a Character

Lab Java Beginner 10 points

Read a character and a number n. Print the character repeated n times, without using String.repeat (it doesn't exist in Java 8).

Input

One line: char n.

Output

One line.

Example

Input

* 5

Output

*****
Sample input available Sample output available
Editor
Java

Hints

Append the character n times in a loop.

Solution explanation

Java 11 added String.repeat; in Java 8 a loop with StringBuilder is the way.

Show solution
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char c = sc.next().charAt(0);
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(c);
        }
        System.out.println(sb);
    }
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD