Can someone send the solution to this question about Annual Revenue in java under looping over statements , my code wont run
The given code declares an array that holds the monthly revenues for a company for a year. You need to calculate the average monthly revenue for the year. For that, calculate the sum of the revenue for all the months and divide it by the number of items in the array. -------------------------------------------- Hint: You can find the number of items in the array using the length property. As the array is of type double, output the result as a double. My code : class program{ public static void main(String[] args){ double[] revenue={10000,12000,13500,9000,5600,6700,23000,7850,8900,10050,12050,13550}; double sum=0; for(int i=0;i<revenue.length;i++){ sum=sum+revenue[i]; } double result =sum/revenue.length; System.out.println(result); Â Â Â Â } }