Object Oriented Programming Lecture 6: Review Mustafa Emre İlal emreilal@iyte.edu.tr
Recap Last week: Arrays + Strings Assignment 05
Today Assignment 05 - Solutions Review In-class coding exercises Thinking in Java – Chapter 6, 7
Assignment 06.1 Find the smallest distance between two neighboring numbers in an array: Write a Java application that creates an array of 500 random doubles between 1-100, and then prints out, the smallest difference between two neighboring numbers and where in the array it exists. e.g. In the sequence 4 8 6 1 2 9 4 the minimum difference is 1 (between 1 and 2). This exists between indexes 3 and 4. Hint: Use Math.abs() to calculate the difference between two numbers.
Assignment 06.2 Check for Anagrams An anagram is a word or a phrase that can be created by rearranging the letters of another given word or phrase. We ignore white spaces and letter case. e.g.: "Desperation" can be rearranged to the phrase "A Rope Ends It". Implement a Java application that looks for all anagrams of a given String in an array of Strings. The array is given below. Pick any to use as the String to search for. Hints: First prepare your Strings: Use .toLowerCase() method to convert all to lower case. Use .toCharArray() to convert the String into a char-array. Remember that char is a subset of int. char can be used in place of int. Try using it as index for an array holding counters for each letter of the alphabet.
Assignment 06.2 Check for Anagrams The words array to be used is: deductions discounted discounter introduces reductions harmonicas maraschino percussion supersonic
Assignment 06.3 Remove duplicate elements Write a Java Application that first creates an array of 20 random integers between 1-20. Prints out this array (on a single line) Then removes duplicate values The application should print out the final array along with its final size.
Next Week Interfaces Inner classes Preperation: Thinking in Java Chapter 8 + 9