Assignment 1: Java Basics - Due 6/16/03 at class

This is a short assignment designed to get your familiar with looking up and using things in the API's classes, creating Objects, calling those Objects methods, as well as getting familiar with the Java environment.
  1. Declare an array of BigIntegers. (The BigInteger class in in java.math. Look up it's API page!) The size of the array should equal the number of command line arguments.
  2. Get the BigIntegers from command line and use them to initialize the array. (Look at what BigIntegers constructors can take as arguments. Since java arguments are Strings, do we need to cast them before sending them to BigIntegers constructors, or are they ok as strings?)
  3. For each pair of numbers (i.e. if there are odd number of numbers, make the final pair the first+last elements in the array), determine and output, in respectable format, the two numbers, their sum, gcd, and result of calling compareTo() and equals() methods.
  4. This last step is going to involve concatenating a lot of strings. This is horribly inefficient in Java using the immutable String type. Using a StringBuffer instead to optimize this.

    Sample input and output:
    > java myFirstAssignment 583490 23423
    Number 1: 583490
    Number 2: 23423
    Sum: 606913
    GCD: 1
    Equals: false
    compareTo: -1

    > java myFirstAssignment 1225 4900 1225
    Number 1: 1225
    Number 2: 4900
    Sum: 6125
    GCD: 1225
    equals: false
    compareTo: 1

    Number 1: 1225
    Number 3: 1225
    Sum: 2450
    GCD: 1225
    equals: true
    compareTo: 0