I wanna create a program that takes input from the user like : 's' means "*" and I want to print it x times. For example if user inputs 4s , the result should be **** or something like that 2s4s : ****** . I tried to user charAt function but could not handle with the numbers ...
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.println("Welcome to image printer program.");
System.out.print("Please enter your sequence:");
String sequence = input.nextLine();
char b = ' ';
int s = 's';
char n = '\n';
for (int a = 0; a <= sequence.length() - 1; a++) {
char c = sequence.charAt(a);
if (c == 's') {
System.out.print("*");
}
}
}