title: Printing a diagonal line within a box in Java
body: <p>For a class project, I must write a code that will print a box made of asterisks with a length specified by a user. There are two types of boxes we must make; basic and diagonal. The basic box is just a normal box made of asterisks, which I have already made. The diagonal box must have a diagonal line inside of it, looking something like this:
  <a href="http://prntscr.com/3fbbot" rel="nofollow">http://prntscr.com/3fbbot</a></p>
  
  <p>Here is the code I have so far:</p>
  
  <pre><code>public static void main(String[] args) {
  
      Scanner type = new Scanner(System.in);
      Scanner number = new Scanner(System.in);
      Boolean f = true;
      while (f) {
          System.out.print("Enter a box type, basic or diagonal: ");
          String g = type.nextLine();
          if (g.equals("basic") || g.equals("diagonal")) {
          }
          else {
              continue;
          }
          System.out.print("Enter a number between 2 - 16: ");
          try {
              int boxSize = number.nextInt();
              if (g.equals("basic")) {
                  if (boxSize &gt;= 2 &amp;&amp; boxSize &lt;= 16) {
                      for (int i = 0; i &lt; boxSize * boxSize;i++) {
                          int row = i / boxSize;
                          int col = i % boxSize;
  
                          if (row == 0 &amp;&amp; col &lt; boxSize-1) {
                              System.out.print("*");
                          }
                          else if (col == 0) {
                              System.out.print("*");
                          }
                          else if (col == (boxSize -1)) {
                              System.out.println("*");
                          }
                          else if (row == (boxSize - 1)) {
                              System.out.print("*");
                          }
                          else {
                              System.out.print(" ");
                          }
                      }
                  }
                  else {
                      System.out.println("Please use a proper integer.");
                  }
                  System.out.print("Make another square? Type yes or no: ");
                  Scanner answer = new Scanner(System.in);
                  if (answer.nextLine().equals("no")) {
                      System.out.print("Thanks for playing!");
                      System.exit(0);
                  }
              }
              else {
  
              }
          }
          catch(Exception e){
              System.out.println("RESETTING. Please type an integer this time.");
          }
      }
  }
  </code></pre>
  
  <p>If you need me to be more specific or need more details, just ask. Thanks in advance.</p>