All pastes #536097 Raw Edit

Someone

public java v1 · immutable
·published 2007-06-04 08:32 UTC
rendered paste body
/* * Problem 1: Write a program that allows you to create  * an integer array of 18 elements with the following  * values: int A[]={3,2,4,5,6,4,5,7,3,2,3,4,7,1,2,0,0,0}.  * The program computes the sum of element 0 to 14 and  * stores it at element 15, computes the average and  * stores it at element 16 and identifies the smallest  * value from the array and stores it at element 17. */public class prob1 {		int A[] = {3, 2, 4, 5, 6, 4, 5, 7, 3, 2, 3, 4, 7, 1, 2, 0, 0, 0};	int sum;	int smallest = 0;		public prob1() {		for(int i = 0; i < 14; i++) {			sum += A[i];		}		A[15] = sum;		A[16] = sum/18;				for(int j = 0; j < 17; j++) {			if(j < smallest) 				smallest = j;		}				A[17] = smallest;		System.out.println("Sum 0-14 : "+sum);		System.out.println("Average of array: "+A[16]);		System.out.println("Smallest value in array: "+smallest);	}			public static void main(String[] args) {       new prob1();	}}