Homework 2 CSPP 51036 due Oct 29 at 11:59pm. Submission instructions -Crate a project in eclipse. See video entitled submitProjects2012 for instructions on how to name your project, tar it, and submit it. ------------------- 1.CurrencyMaker: (10 points) Use the java.util.Currency class to write a program called CurrencyMaker that takes as input a valid ISO 4217 currency code (Google it -- e.g. "USD", etc.) and prints out the currency "symbol" for USD only (e.g. "$"). You may need to use the following syntax: System.out.println(curCurrency.getSymbol(Locale.US)); The driver class with the executable main method should be called CurrencyMaker. Exceptions/Errors handled: Currency.getInstance(strCode) throws an exception if you supply a bad currency code. If thrown, catch this exception, print out a nice message reminding the user what he must suppy, and return. No need to have a loop which asks the user over and over until exit is typed. ------------------- 2. ArrayListPrinter: (10 points) Create an array of String called strSports; Declare and initilaize the array in one statement like this: String[] strSports = {"Squash", "Baseball", "Football", "Golf", "Badminton"}; Iterate over this array using a foreach loop printing each element to the console. Iterate over this array using a for loop (e.g. use nC as a counter) printing each element to the console. Iterate over this array but only print those sports that end with the letters "ball". Iterate over this array, but only print elements with even indices (e.g. 0,2,4). clue: better to use a for loop. Declare and instantiate an ArrayList of String like this: ArrayList strCountries = new ArrayList(); add at least 5 countries to this ArrayList, of which at least two must end with "stan" such as Afganistan, Kazakhistan, Kyrgystan, Pakistan, Turkmeinistan,Uzbekistan, Tajakistan. Iterate over this ArrayList using a foreach loop and print out the elements to the console. Iterate over this ArrayList using a for loop (e.g. use nC as a counter) and print out the elements to the console. Iterate over this array (using either for or foreach) but only print those countries that end with the letters "stan". Iterate over this ArrayList, but only print elements with even indices (e.g. 0,2,4). clue: better to use a for loop. The driver class [the one with the executable main method] should be called ArrayListPrinter. Exceptions/Errors handled: none ------------------- 3.MyAsciify: (10 points) Create a new package called ascii. Copy Asciify.java (located in examples directory of course-content) into your new package. Asciify is a driver, but has some static utility functions as well. Create a driver class called MyAsciify.java. Prompt the user for the url to an image on the internet or on your local machine. Also ask for a dimension (around 100 will produce good results). Then call Asciify.getAsciiChars(strImageUrl, nDim). This method returns char[][]. Iterate over this two-dimensional array of chars printing its contents to the conole. Exceptions/Errors handled: inputs from user; if dimension not an integer, then print out a nice message reminding the user what he must supply, and return. ------------------- 4. RollCall: (20points) Within your eclipse project, crate a package called rollcall. Create an abstract Person class Fields: private String strName Constructors: Person(String strName) Methods: public abstract String vocalize(); create a getter and setter for strName Note: With abstract methods, you do NOT write the implmentation, just the signature. This forces any extending class to implement this method. Also, you can never instantiate a Peron object (but you can store sub-class objects in a Person reference). Create a Student class that extends Person Fields: private String strNationality private String strSport Constructors: Student(String strName, String strNationality, String strSport) //call super(name) within this constructor Methods: public String vocalize(); //this method will return "My name is " + name + " I'm " + nationality + " and I play " + sport. implement getters and setters for fields Create a Teacher class that extends Person Fields: none Constructors: Teacher(String strName) //call super(strName) within this constructor Methods: public String vocalize(); //this method will return "My name is " + name + ". Roll call please: " ------------------- In the RollCall class (which is the driver and has an executable main method), Create an ArrayList of Person, e.g. ArrayList Add one Teacher, and at least 5 Students. Iterate over this ArrayList calling the vocalize() method of each element and printing the results to the console. Exceptions/Errors handled: none ------------------- 5. (20 points) Write a program that computes the product of two integer matrices [2-dimensional arrays]. You can populate the matrices with random values. Time this routine using the appropriate java System methods and graph the execution time as a function of matrix size. For example, the first iteration, mutiples two 2x2 matrices. [14][-512] [68][10] x [39][-6] [-85][908] the second iteration multiplies two 3x3 matrices. [144][912][6] [-98][101][-4] [48][15][-49] x [14][-212][6] [98][151][46] [47][45][99] and so on to 20. You can use a horizontal histogram to graph the results. ------------------------ 6. (30 points) Within your eclipse project, crate a package called date. Using NO date-specific Java libraries, write a program that computes the number of days between any two dates (inclusive). You must take into account leap years. The rule for computing a leap year is as follows: If the year is divisible by 4 it is a Leap Year ... Unless the year is divisible by 100, then it is _not_ a Leap Year ... Unless the year is divisible by 400, then it _is_ a Leap Year. During a Leap year, an extra day is added at the end of the month of Feb. ex. 1000 is not a Leap Year 2000 is a Leap year Create your own date class called MyDate, which has day, month, year as fields, has a method called addDay() and implements the Comparable interface. Create a driver class called DayCounter.java. Error checking. Be sure to handle at least the following: - if there is too few or too many input parameters - if the date strings are not in the proper format (simply echo usage statement); - if date 1 is not earlier than date 2 ------------------------