Your Turn to Do It by Hand – Intro to Java Programming


Here is that formula written out in Java. Have a close look at the parenthesis. I was very careful to compute the entire expression, then have parenthesis around it, and only then take the integer part of the final answer. Now we are almost home free. The red tiles was the same as the pairs and the y tiles as the pairs plus one. Here I’m running the program and when I supply the same inputs as in the example problem, a 100 inches for the width. Tile size of 5, then I get the expected answer. Now the important part of this entire exercise is to first do it by hand. If you can’t do it by hand, you can’t program it. And doing it by hand gives you valuable intuition that you need to write the Java code. You’ll get to practice this with another example that Sarah will show you.

One thought on “Your Turn to Do It by Hand – Intro to Java Programming

  1. You wrote System.out.println("Red tiles: " +whiteTiles); when it should've been System.out.println("White tiles: " +whiteTiles).

Leave a Reply

Your email address will not be published. Required fields are marked *