Created
August 16, 2017 06:48
-
-
Save thanapongp/ce125774c2c748e491d2f336f9570057 to your computer and use it in GitHub Desktop.
something.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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