CSC-212 - Assignment #1
Due: Tuesday, April 9th, at 11:45 AM Central Time.
This assignment will push you to make sure that you have a handle on methods and arrays.
This is not meant to be a difficult assignment. However, if you do not have a good grasp of the material, it may seem difficult. In that case, the way to learn this material is to carefully and with lots of practice review the concepts covered in this week’s lectures.
However, you absolutely must learn this material. The course will be a miserable experience and probably un-passable without it. So please make absolutely sure that you invest the time over the next few days and weekend to make sure that you learn this material.
Reviewing this week’s lectures (log in to COL to view them) with frequent use of the pause button is really the key. Make sure you type EVERY example as it is demonstrated, and then experiment with the example by modifying it.
All of the questions below can be answered in a single class. As part of your class you should have a main method in which you invoke each method at least once.
1) Write a method that accepts three integers and returns the highest of those three integers. For example: findHighest(3, 5, -11); would return 5. Overload this method to accept three doubles and return the highest of those doubles.
2) Write a method that accepts an array of integers and returns the lowest integer in that array. Overload to accept an array of doubles.
3) Write a method that accepts an array of Strings and outputs each item in the array on each line. So: outputStrings(studentNames); would output each item in the array ‘studentNames’ with one name on each line.
4) Write a method that returns an array of integers. The method should accept two intergers: The first integer represents the size of the array, and the second integer represents what each element of the array should be initalized to. So: createArray(5, 99); would:
a. Create an array of integers of size 5.
b. Set each element of the array to the value 99.
c. Return the array that was created inside the method.
Remember to observe good programming habits. These include:
o Well-chosen identifiers that make your code clear
o Use (but not overuse!) of whitespace
o Commenting your methods. The comments do not have to be long, but they DO have to indicate what the method does and what it returns (if it is not a void method).
o Submit to the D2L dropbox. As will be the case throughout the quarter, the due date is Tuesday at 11:45 Central Time.
o You can submit up to 2 days late (Thursday at 11:45) albeit with a 10% penalty for each day late.
o Please remember not to wait until the last minute in case you run into glitches with D2L or your own computer.