👤

Answer :

We will use Java to write the code with utility class is Scanner.

What is scanner in Java?

Scanner is class from util package in Java for read input in Java language. So the code is,

import java.util.Scanner;

public class Main {

   public static void main(String[] args) {

       // scanner object to take user inputs

       Scanner sc = new Scanner(System.in);

       // asking the user to input string value

       System.out.println("Input a String:");

       String str = sc.nextLine();

       // asking the user to input int value

       System.out.println("Input an integer:");

       int num = sc.nextInt();

       // loop for getting each char

       for (int i = 0; i < str.length(); i++) {

           char Char = str.charAt(i);

           // loop for n times of current char

           for (int j = 0; j < num; j++) {

               System.out.print(Char);

           }

       }

       System.out.println();

   }

}

Learn more about Java here:

brainly.com/question/26642771

#SPJ4

Go Teaching: Other Questions