Let's look at the second problem in the first assignment. We first worked a "solution" in Python: size = int(raw_input("Welcome, what size:")) for line in range(size): for column in range(size): if line == 0 or line == size-1 or line == column: print "*", else: print " ", print This runs as follows: >>> ================================ RESTART ================================ >>> Welcome, what size:9 * * * * * * * * * * * * * * * * * * * * * * * * * >>> >>> ================================ RESTART ================================ >>> Welcome, what size:21 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>> So it's not exactly what we want. But we discussed how it does it and that it's close. So let's discuss how we do this in Java: So we start with: class Pattern { public static void main(String[] args) { } } Save it in Pattern.java (on the Desktop maybe). Then compile and run it to be sure you don't have errors. Here's how it went for me: Microsoft Windows [Version 6.0.6001] Copyright (c) 2006 Microsoft Corporation. All rights reserved. C:\Users\dgerman>cd Desktop C:\Users\dgerman\Desktop>"C:\Program Files\Java\jdk1.6.0_13\bin\javac.exe" Pattern.java C:\Users\dgerman\Desktop>java Pattern C:\Users\dgerman\Desktop> So let's change the program to allow for user input. We are being told to go to java.util (store, like Lowe's) and buy a Scanner for that. If you Google java scanner your first found link is: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html There right at the top you can read this (among others examples): For example, this code allows a user to read a number from System.in: Scanner sc = new Scanner(System.in); int i = sc.nextInt(); So that settles it, and the code becomes: import java.util.*; class Pattern { public static void main(String[] args) { int size; System.out.print("Welcome, what size: "); Scanner who; who = new Scanner(System.in); size = who.nextInt(); System.out.println("So you want a size " + size + " square."); } } C:\Users\dgerman\Desktop>"C:\Program Files\Java\jdk1.6.0_13\bin\javac.exe" Pattern.java C:\Users\dgerman\Desktop>java Pattern Welcome, what size: 13 So you want a size 13 square. C:\Users\dgerman\Desktop>java Pattern Welcome, what size: 21 So you want a size 21 square. C:\Users\dgerman\Desktop> So here's an example of using a for to print 5 stars on the same line: class Pattern { public static void main(String[] args) { int size = 5; for (int line = 0; line < size; line = line + 1 ) System.out.print("* "); } } The for inside is like while. The basic template is for (initial ; condition; increment) { do this } The equivalent in while of the for above is immediate: initial while (condition) { do this increment } So we can and should use { ... } to delimit blocks of statements. This code follows what we did in Python and produces a 15x15 square of *'s. class Pattern { public static void main(String[] args) { int size = 15; for (int line = 0; line < size; line = line + 1 ) { for (int column = 0; column < size; column += 1) { System.out.print("* "); } System.out.println(); } } } So what next? We need to selectively print stars in this square. class Pattern { public static void main(String[] args) { int size = 15; for (int line = 0; line < size; line = line + 1 ) { for (int column = 0; column < size; column += 1) { if (line - column == 0 || line + column == size-1) { System.out.print("* "); } else { System.out.print(" "); } } System.out.println(); } } } That just about does it. Curly braces define blocks of statements. They are not needed when the blocks have less than one statement in them. They are necessary when you have 2 or more statements in the block. So use them even if you don't need them because you'll be safe later. If you add a statement to a block that's defined with {'s you can't go wrong. If the {'s are not there you'd have to add them. So use them and you never need to worry about this. Also the boolean operators in Java are: && for and, || for or and ! for not. Let's discuss the last problem too. So we create Magic.java that looks like this: class Magic { public static void main(String[] args) { } } Next I declare and create (initialize) a two dimensional array of integers: class Magic { public static void main(String args[]) { int size = 3; int square[][]; square = new int[size][size]; for (int i = 0; i < square.length; i++) { for (int j = 0; j < square[i].length; j++) { System.out.print(square[i][j] + " "); } System.out.println(); } } } I also printed it for you. So when I am done this program prints as follows: C:\Users\dgerman\Desktop>java Magic 0 0 0 0 0 0 0 1 0 -------------------------- 0 0 2 0 0 0 0 1 0 -------------------------- 0 0 2 3 0 0 0 1 0 -------------------------- 4 0 2 3 0 0 0 1 0 -------------------------- 4 0 2 3 5 0 0 1 0 -------------------------- 4 0 2 3 5 0 0 1 6 -------------------------- 4 0 2 3 5 7 0 1 6 -------------------------- 4 0 2 3 5 7 8 1 6 -------------------------- 4 9 2 3 5 7 8 1 6 -------------------------- C:\Users\dgerman\Desktop> You see how the numbers are placed in a 3x3 square that turns into a magic square. As mentioned in the problem statement it is magic because at the end numbers on the rows, columns and diagonals sum up to 15.