Skip to content

Instantly share code, notes, and snippets.

@thanapongp
Created August 16, 2017 06:48
Show Gist options
  • Select an option

  • Save thanapongp/ce125774c2c748e491d2f336f9570057 to your computer and use it in GitHub Desktop.

Select an option

Save thanapongp/ce125774c2c748e491d2f336f9570057 to your computer and use it in GitHub Desktop.
something.java
import java.util.Scanner;
public class HelloWorld
{
public static void main(String[] args)
{
int numbers[] = new int[100];
int i = 0;
int sum = 0;
Scanner reader = new Scanner(System.in);
do {
System.out.printf("Enter number [%d]: ", i);
int input = reader.nextInt();
if (input == 0) break;
numbers[i++] = input;
sum += input;
} while (i < 100);
reader.close();
float average = sum / (i + 1);
System.out.printf("Average: %.3f", average);
int count = 0;
int j = 0;
while (j < i) {
if (numbers[j] < average) count++;
j++;
}
System.out.printf("Count: %d", count);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment