CodeLab 11.06.06

CodeLab 11.06.06 - CodeLab: 11.06.06 printArray is a method...

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

View Full Document Right Arrow Icon
CodeLab : 11.06.06 printArray is a method that accepts one argument, an array of int s. The method prints the contents of the array; it does not return a value. inventory is an array of int s that has been already declared and filled with values. Write a statement that prints the contents of the array inventory by calling the method printArray. printArray(inventory); Write the definition of a method printArray, which has one parameter, an array of int s. The method does not return a value. The method prints out each element of the array, on a line by itself, in the order the elements appear in the array, and does not print anything else. public void printArray(int[] s) { for(int i = 0; i < s.length; i++) { System.out.print(s[i]); System.out.println(); } } Declare and instantiate an array named scores of twenty-five elements of type int. int[] scores = new int[25]; Write a statement that declares an array named streetAddress that contains exactly eighty elements of type char. char[] streetAddress = new char[80]; Declare an array named a of ten elements of type int and initialize the elements (starting with the first) to the values 10, 20,. .., 100 respectively. int[] a = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; Declare an array named taxRates of five elements of type double and initialize the elements (starting with the first) to the values 0.10, 0.15, 0.21, 0.28, 0.31, respectively.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/29/2008 for the course CS 302 taught by Professor Willbenton during the Fall '07 term at Wisconsin.

Page1 / 3

CodeLab 11.06.06 - CodeLab: 11.06.06 printArray is a method...

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

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