Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package average;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- public class Average {
- public static void main(String[] args) throws FileNotFoundException {
- Scanner in = new Scanner(new File("averageme.txt"));
- int total = 0;
- int average = 0;
- int i = 0;
- while(in.hasNextInt()) {
- int a = in.nextInt();
- total = total + a;
- i++;
- average = total/i;
- System.out.println("int " + i + " is\t" + a + "\tnew average is " + average);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement