ArrayTest1 - double...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class ArrayTest1 { // Store the following data items in an array // then calculate their sum and average using a for-loop. // Print out the results. // 3.2, 2.4, 6.6, 7.3, 4.2, 9.9, 12.0, -3.2, -4.1, 5.4 // Later, convert the class to use a while-loop // instead of a for-loop. / public static void main (String [] args) {
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: double values={3.2,2.4,6.6,7.3,4.2,9.9,12.0,-3.2,-4.2,5.4}; double sum = 0.0; double average=0.0; for(int i =0; i<10; i++); { sum+=values[10]; } average=sum/values.length; System.out.println("sum="+sum); System.out.println("Average="+average); } }...
View Full Document

This document was uploaded on 04/14/2010.

Ask a homework question - tutors are online