Preview:
// Initialize a Scanner
static Scanner s = new Scanner(System.in);

public static void main(String[] args) {
  System.out.println("Enter a number");
  printForUser("foo");

  System.out.println("Enter another number");
  printForUser("foo2");
  
  System.out.println("Enter yet another number");
  printForUser("foo3");
}
public static void printForUser(String printedText) {
  // Store a number from user input
  int n = s.nextInt();
  
  // Print the text for the amount stored
  for (int i = 0; i < n; i++) {
    System.out.println(printedText);
  }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter