// Initialize a Scanner static Scanner s = new Scanner(System.in); public static void main(String[] args) { // Store a number from user input System.out.println("Enter a number") int firstNum = s.nextInt(); // Print "foo" for the amount stored for (int i = 0; i < firstNum; i++) { System.out.println("foo"); } // Store another number from user input System.out.println("Enter another number") int secondNum = s.nextInt(); // Print "foo2" for the amount stored for (int i = 0; i < secondNum; i++) { System.out.println("foo2"); } // Store yet another number from user input System.out.println("Enter yet another number") int thirdNum = s.nextInt(); // Print "foo3" for the amount stored for (int i = 0; i < thirdNum; i++) { System.out.println("foo3"); } }
Preview:
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