Discover how IDNLearn.com can help you find the answers you need quickly and easily. Join our knowledgeable community and access a wealth of reliable answers to your most pressing questions.
Sagot :
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
Thank you for being part of this discussion. Keep exploring, asking questions, and sharing your insights with the community. Together, we can find the best solutions. IDNLearn.com is committed to providing the best answers. Thank you for visiting, and see you next time for more solutions.