9.10 Exercises


9.10 Exercises

  1. Design and implement a function named mintemp for class Temp. This function should find the element of array temp with the minimum value. The function must return the index value of the corresponding element.

  2. Design and implement a function that computes the standard deviation of the temperature values in array temp. The standard deviation measures the spread, or dispersion, of the values in the array with respect to the average value. The standard deviation of array X with N elements is defined as:

    where

  3. Design and implement a function for class Temp that sorts the array of temperature values using insertion sort. This divides the array into two parts. The first is initially empty; it is the part of the array with the elements in order. The second part of the array has the elements in the array that still need to be sorted. The algorithm takes the element from the second part and determines the position for it in the first part. To insert this element in a particular position of the first part, the elements to the right of this position need to be shifted one position to the right. Note: insertion sort is not explained in this book; look it up on the Web.

  4. Design and implement a problem that provides the rainfall data for the last five years. For every year, four quarters of rainfall are provided measured in inches. Class Rainfall includes attributes such as the precipitation (in inches), the year, and the quarter. Class Mrainfall declares an array of object references of class Rainfall. The problem should compute the average, minimum, and maximum rainfall per year and per quarter (for the last five years). Hint: use a matrix.

  5. Redesign and reimplement the solution for Exercise 1 with an array parameter definition in the function. Use the appropriate call to the function.

  6. Redesign and reimplement the solution for Exercise 2 with an array parameter definition in the function. Use the appropriate call to the function.

  7. Redesign and reimplement the solution for Exercise 3 with an array parameter definition in the function. Use the appropriate call to the function.

  8. Design and implement a problem that provides the rainfall data for the last five years. For every year, twelve months of rainfall are provided measured in inches. Class Rainfall2 includes attributes such as the precipitation (in inches), the year, and the month. Class Mrainfall2 declares an array of object references of class Rainfall2. The problem should compute the average, minimum, maximum, and standard deviation of rainfall per year and per month (for the last five years). Hint: use a matrix.




Object-Oriented Programming(c) From Problem Solving to Java
Object-Oriented Programming (From Problem Solving to JAVA) (Charles River Media Programming)
ISBN: 1584502878
EAN: 2147483647
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net