Assessment 3_7_sample

Instructions

This assessment is designed to be completed in 10 minutes or less.

Copy the template below and get all the test cases to pass. Hard-coding answers will not receieve credit; your solution must work for valid arrays.

The problem

Imagine the user enters a list of integers. Count how many adjacent numbers sum to 10, and report this number. For example, if the user enters the list [2,7,3,1,9,5,5,4,6,8], your code would return 4.

Code Template and Test cases

public class Assess3_7_Sample{

  public static int sumCount(int[] original){
    return -9999999;
  }

  public static void main(String[] args){
      int [] arr1 = {};
      System.out.println("test1: " + (sumCount(arr1) == 0));
      int [] arr2 = {1};
      System.out.println("test2: " + (sumCount(arr2) == 0));
      int [] arr3 = {5, 5};
      System.out.println("test3: " + (sumCount(arr3) == 1));
      int [] arr4 = {5,5,6,4,8};
      System.out.println("test4: " + (sumCount(arr4) == 2));
      int [] arr5 = {2,7,3,1,9,5,5,4,6,8};
      System.out.println("test5: " + (sumCount(arr5) == 4));
      int [] arr6 = {10};
      System.out.println("test6: " + (sumCount(arr6) == 0));

  }

}