repeated code

PHOTO EMBED

Tue Oct 18 2022 19:07:45 GMT+0000 (Coordinated Universal Time)

Saved by @DonYall #java

// 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");
  }
}
content_copyCOPY