We would like to find the average of the following floating point number:
11.1, 1.1, 111.113, 111.411, 114.115
You can use array to store the numbers
Here is the code structure you can use.
public class Main { public static void main(String args[]) { System.out.println("Average is "); } }
// Average an array of values. public class Main { public static void main(String args[]) { double nums[] = {11.1, 1.1, 111.113, 111.411, 114.115}; double result = 0; for(int i=0; i<5; i++) { result = result + nums[i]; } System.out.println("Average is " + result / 5); } }