All pastes #766065 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-11-08 16:20 UTC
rendered paste body
import java.util.*;
public class Averages {

        public static void main (String[] args) {

 		// make scanner object

        Scanner kybd = new Scanner(System.in);

 		// delcare primitives

        double num, average;
        double sum = 0;

 		// loop, exercute the input code inside the loop

                for (int i = 1; i<11; i++ )     {

        System.out.print("Please enter your number: ");

 		// input code

        num = kybd.nextInt();

        System.out.println("You enterted: " + num);

 		// add the input to the sum

        sum += num;

        System.out.println("Total of sum: " + sum);

 		// if loop is on 10th loop execute below code

        if(i==10) {
 						// average equals the sum total devided by the number of loops(inputs)
                        average = sum / i;

                        System.out.println("\nAverage of sum is: " + average);

                        }

                }
        }
}