ICS 211 Homework 1

Java Review and Recursion

Part 1: Java Review

Write a Java application that:

Part 2: Recursion

Write a Java application that executes 4 methods, 2 iterative and 2 recursive.

Your program must accept an integer Q on the command line. This integer is the input for all 4 methods. If the command line has anything other than a single integer, your program should print an error message and exit.

If the integer Q is negative or zero, your program should exit without printing anything.

Otherwise, execute each of the following four methods:

  1. Method 1: use a loop to print a row of Q asterisks
  2. Method 2: use recursion to print a row of Q asterisks
  3. Method 3: use a loop to print the numbers Q, Q - 1, ... 3, 2, 1
  4. Method 4: use recursion to print the numbers Q, Q - 1, ... 3, 2, 1

Turning in the Assignment

Email your assignment to the TA following the instructions posted here.

Since this assignment requires you to turn in two classes, they should be named named LastNameFirstNameXY.java, where X is the assignment number and Y is the part number. So for example, for this assignment I would send in BiagioniEdoardo11.java and BiagioniEdoardo12.java.

Grading

The two parts of the assignment are each graded on a scale of 0..100, using the TA's grading guidelines as if they were independent assignments. The two grades are then combined into one by adding them together and dividing the result by two.