At Westonci.ca, we make it easy to get the answers you need from a community of informed and experienced contributors. Experience the convenience of finding accurate answers to your questions from knowledgeable professionals on our platform. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.
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 your visit. We're dedicated to helping you find the information you need, whenever you need it. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.