Assignment #2

Instructions

  1. The purpose of this assignment is to practice using arrays and loops.
  2. Write a Java application that does the following.
    1. Here is starter code for your assignment: LastNameFirstName02.java. Download it to your computer and change the name of the file and name of the class to your last name and first name. Change the comments as appropriate.
    2. In order to bring place-based science and Hawaiian culture into our class, I would like you to select one of the following data sources for this assignment, which you can re-use or switch for future assignments:
      1. At Leeward CC, between the Hālau and the BS building, and across the street from the Hālau, there is a garden of endemic and Hawaiian plants. This is a chance to look at and learn something of interest about these endemic and Hawaiian plants. Each plant has a plack with information about the plant. You can also go on a virtual hike with Sam Gon III from The Nature Conservancy of Hawai'i: Nowhere Else on Earth: Indigenous Plants of Hawaii. Sam is a very knowledgeable native Hawaiian conservationist. You can easily collect the Hawaiian name, scientific name, and other attributes from the video.
      2. Watch the YouTube video: Unique birds of Hawai'i. This short video is about Jack Jeffery, the foremost native Hawaiian bird photographer. It presents a short but very meaningful tale about some of these birds. From the video, you sudents should be able to collect the Hawaiian and common name of several birds along with a few attributes (by watching and listening) for each (e.g., feather color, bill shape). A supplemental video on native Hawaiian birds that you could also reference is: Hawai'i Native Forest Birds, which has Hawaiian and scientific names.
      3. Visit DA 104 at Leeward CC and look at the Royal Hawaiian Family portraits on the walls. From the portraits, you can find such data as names, birth and death dates, family relationships, significant achievements, etc.
      4. Take a look at the Hawaiian Star Compass. This compass is used by Nainoa Thompson and other Hawaiian navigators. You can use each "house" and attributes of each "house" as data in your assignment.
    3. Find at least seven (7) unique Plants of Hawai'i, Birds of Hawai'i, Royal Hawaiian Family members, or Hawaiian Star Compass houses. For the example output below, I did "Marine Mammals of Hawai'i" as an example.
    4. Then, figure out three attributes for each Plant of Hawai'i, Bird of Hawai'i, Royal Hawaiian Family member, or Hawaiian Star Compass house. For example, some attributes for plants are the scientific name, Hawaiian name, and height. Some attributes for birds are the Hawaiian name, color, and size. Some attributes for Royal Hawaiian Family members are their name, date of birth, and age at death. Some attributes for Hawaiian Star Compass houses are their name, degree on the compass, and associated rising star. Display your theme at the top of the output for your program.
    5. Declare and instantiate three (3) arrays for your three (3) attributes. For example, I used an array of seven (7) Strings for the names of the marine mammals, an array of seven (7) Integers for the population, and an array of seven (7) Doubles for the length.
    6. Write a for-loop to display the three arrays, showing the corresponding indexes and elements. You should just display "null" for the values at this point. If you used primitive data types instead of classes, such as "double" instead of "Double" that is OK. Instead of displaying "null" you might get zeros (such as "0.0" for doubles) instead.
    7. Initialize the elements in the arrays to specific values.
    8. Write a for-loop to re-display the three (3) arrays, showing the corresponding indexes and elements.
    9. Change all elements to different values. Just keep it simple. For example, I capitalized the names, added one (1) to the populations, and converted meters to centimeters.
    10. Write a for-loop to re-display the three (3) arrays, showing the corresponding indexes and elements.
    11. Write your original comments every 3-5 lines of code.
    12. Make sure your code follows the ICS 211 Java Coding Standard, in particular the Java documentation (Javadoc) comments that go above each method.
    13. REMINDER: Please do NOT use Hawaii Marine Mammals as your topic. Your output format should be similar to the example output format, but you should use different data from a different topic. Your formatting does not need to exactly match my formatting. Just make sure it is neat and easy to read. You can also change the data in a different way than I did. For example, instead of adding one to each array element, you can add two. This is up to you. The intent is for students to practice changing the value of each element in each array. In other words, make sure you change the value of each element. Do NOT just change the output.
      For example, this code changes the value of an element:
      population[i] = population[i] + 1;
      This code only changes the output:
      System.out.println(population[i] + 1);

Output

The output of your program should be similar to the example output below.

Marine mammals of Hawai'i

index   name   population   length
  0     null      null       null
  1     null      null       null
  2     null      null       null
  3     null      null       null
  4     null      null       null
  5     null      null       null
  6     null      null       null

index   name                population    length(meters)
  0     Hawaiian monk seal        1100      2.40
  1     humpback whale           10000     16.00
  2     spinner dolphin           3351      2.35
  3     bottlenose dolphin         235      3.50
  4     pilot whale               8850      3.70
  5     pygmy killer whale         817     20.50
  6     false killer whale         150      2.80

index   name(all caps)     population(+1) length(centimeters)
  0     HAWAIIAN MONK SEAL        1101    240.00
  1     HUMPBACK WHALE           10001   1600.00
  2     SPINNER DOLPHIN           3352    235.00
  3     BOTTLENOSE DOLPHIN         236    350.00
  4     PILOT WHALE               8851    370.00
  5     PYGMY KILLER WHALE         818   2050.00
  6     FALSE KILLER WHALE         151    280.00