program3

program3 - /* * Program 3 * Name: Xin Chi *Class Comp 401 I...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/** * Program 3 ** Name: Xin Chi *Class Comp 401 I *nstructor Hedlund *Section 1 Pledge: * I have neither given nor received unauthorized aid on this program. * */ public class program3 { private static int[] dht; public static void main(String[] args) { testDaysAbove89(); testLastDayAbove89(); testLongestHotSpell(); } // Pre: temp.length > 0 // Post: return number of days for which the temperature // was above 89 public static int daysAbove89(int[] temp) { int count = 0; for (int t : temp) { if (t > 89) { count++; } } System.out.println("days above 89 is " + count); return count; } // Input Expected Return // [90, 78, 91, 42, 99] 3 // [78, 42, 31, -5] 0 // complete this test plan public static void testDaysAbove89() { dht = new int[] { 90, 78, 91, 42, 99 }; daysAbove89(dht); dht = new int[] { 78, 42, 31, -5 }; daysAbove89(dht); dht = new int[] { -30, 0, 90, 89 }; daysAbove89(dht); dht = new int[] { 89 }; daysAbove89(dht); dht = new int[] { 90, 91, 89, 88, 95, -3, 97 }; daysAbove89(dht); } // Pre: temp.length > 0 // Post: return the index of the last day in the array
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
// for which the temperature was above 89 decrees. public static int lastDayAbove89(int[] temp) {
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/10/2011 for the course COMP 110 taught by Professor Stotts during the Spring '08 term at UNC.

Page1 / 3

program3 - /* * Program 3 * Name: Xin Chi *Class Comp 401 I...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online