Lab 1

JAVA 8 API

Instructions


Part 1: Using Arrays

You will COMPLETE THIS application program that will compute a statistical analysis.
Further information provided inside of the class.

Part 2: Sorting

Create a new class called "Utility". Inside of Utility, create two methods:

/** prints the given list */
public static void printList(int[] someList)

/** returns the given list in the desired order
* Direction will either be "ASC" or "DESC" written in all caps just how it appears here.
* ASSUME that there will be no typing errors (user will either write ASC or DESC correctly.)
*/
public static int[] sort(int[] someList, String direction)

To test your methods, uncomment the items commented out for part 2.
PURPOSE OF THIS LAB: Think how to sort! Use pencil/paper to come up with an algorithm.

Part 3: Date Arithmetic

Put your app prog in a class called "Part3".

Create a program that will input two dates from a user. (Use the Scanner class.) You should ask for a MONTH, DAY, and YEAR for each of the two dates. Your program should then return the number of days between the two dates.

NOTE: I am leaving the implementation entirely up to you. You may want to create Time classes and then use some type of date arithmetic.
*Another option is to use a 2d array that keeps track of the month, number of days that month has, and elapsed days of the year. You can then have two variables for the year of each date and use the 2d array to calculate days elapsed. (Remember leap year!)
int[][] monthAndDays = { {1, 31, 31}, {2, 28, 59}....... };
// (note that the 28 could be a 29 some years)

Part 4: Palindromes

This is a fun one!
Create a program that can accomplish two tasks:
1. Determine if a given word (String) is a palindrome
2. Provided a String (or array of char [you need the API here]), produce a palindrome based upon what was input.

You should do all of this inside of an application program called "Part 4".

The program should work as follows:
It displays to the user "Press 1 to test a word, Press 2 to create your own palindrome"
If the user enters a 1
-------Ask for a word, then call a method public boolean isPalindrome(String word) that returns true if it is, false if it is not.
-------Tell the user if they entered a palindrome.
If the users enters a 2
------Ask for a sequence of letters.
-----Then call a method public String createPalindrome(String word) that returns a palindrome with that sequence.

EXAMPLE
user enters a 1: types "radar", program prints "Yes, that's a palindrome!"
user enters a 1: types "salalalad", program prints, "No, that is not a palindrome."
user enters a 2: types "abcdef", program prints, "Your palindrome is: abcdeffedcba"

Part 4 Extension: ENHANCED CREATE PALINDROME
If a user enters a 2: THEN ASK if they would like to duplicate the final character in the array
If they say YES, then it should appear like the example above ("abcdeffedcba")
If they say NO, then it should appear like ("abcdefedcba")

****YOU WILL DEFINITELY NEED TO VISIT THE API FOR HELP WITH STRING MANIPULATION****