How to Find the Average With Netbeans
- 1). Start a new project. Select "Java," then select "Java Application." Give the project a name, such as "average." Create a main class called "Average."
- 2). Write the code to find an average in the "Average" class:
class Average{
public static void main(String[] args){
int[] counts = {1, 2, 3, 4, 5, 6, 7, 8, 9};
int sum = 0;
for (int i : counts){
sum += i;
} (Source 3)
int average = sum / counts.length; //the sum of the numbers divided by the number of values
System.out.println(average);
}
} - 3). Click the green execute arrow located in NetBean's top menu bar to run the program. The output will appear in the debugging window at the bottom of the NetBeans window.
Source...