title: Draw a heart in ASCII-art style based on user input
body: <p>I have a problem that I hope you can help with.</p>
  <p>The Java program should print hearts in ASCII-art style, based on the input <code>N</code> given by a user.</p>
  <p><strong>Information:</strong></p>
  <ul>
  <li>Characters to print: ♡ ♥</li>
  <li>The printing of the <em>top</em> and <em>bottom</em> part of the heart can be done separately.</li>
  <li>The solution must be based on for-loops.</li>
  <li><code>N</code> determines the top part of the heart:
  <ol>
  <li><em>The slanted outer sides at the top have <code>N</code> hearts in them.</em></li>
  <li><em>The flat parts at the top have <code>N</code> hearts in them.</em></li>
  <li><em>The gap between the two flat parts is <code>N</code> hearts wide.</em></li>
  </ol>
  </li>
  </ul>
  <p><strong>Examples:</strong></p>
  <ul>
  <li><a href="https://i.stack.imgur.com/fICix.png" rel="nofollow noreferrer">N = 1</a></li>
  <li><a href="https://i.stack.imgur.com/BzKm5.png" rel="nofollow noreferrer">N = 2</a></li>
  <li><a href="https://i.stack.imgur.com/7zIEP.png" rel="nofollow noreferrer">N = 3</a></li>
  <li><a href="https://i.stack.imgur.com/IkiUf.png" rel="nofollow noreferrer">N = 4</a></li>
  </ul>
  <p><strong>My current code:</strong></p>
  <pre class="lang-java prettyprint-override"><code>public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      System.out.println(&quot;Enter the number of hearts you want to print&quot;);
      int userInput = scan.nextInt();
  
      printTop(userInput);
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>public static void printTop(int userInput) {
      String row = &quot;&quot;;
      int width = 2 * (userInput - 1) + 3 * userInput;
      for (int height = 0; height &lt; userInput; height++) {
          for (int i = 0; i &lt; userInput - 1; i++) {
              row += &quot;♡&quot;;
          }
          for (int i = 0; i &lt; userInput; i++) {
              row += &quot;♥&quot;;
          }
          for (int i = 0; i &lt; userInput; i++) {
              row += &quot;♡&quot;;
          }
          for (int i = 0; i &lt; userInput; i++) {
              row += &quot;♥&quot;;
          }
          for (int i = 0; i &lt; userInput - 1; i++) {
              row += &quot;♡&quot;;
          }
          row += &quot;\n&quot;;
      }
      System.out.println(row);
  }
  </code></pre>
  <p><strong>Thoughts:</strong></p>
  <ul>
  <li>The first line of the heart is based on:
  <pre><code>2 * (userInput - 1) + 3 * userInput
  </code></pre>
  </li>
  <li>The <em>colored hearts</em> must increase by 2 for each line.</li>
  <li>The <em>center hearts</em> must be reduced by 2 for each line.</li>
  <li>The <em>transparent hearts</em> on the side must be reduced by 1 for each line.</li>
  </ul>
  <p><strong>Questions:</strong></p>
  <ul>
  <li>How can I get the different types of hearts to do their &quot;job&quot; on each line?</li>
  </ul>