Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class Average {
- public static void main(String args[]) {
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- int i = 0;
- double sum = 0.0;
- double num;
- double ave = 0.0;
- String str;
- try {
- while ((str = br.readLine()) != null) {
- num = Double.parseDouble(str);
- i++;
- sum += num;
- }
- }
- catch (Exception e) {
- }
- ave = sum / i;
- System.out.println("平均 = " + ave);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement