Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class AvgOfASeriesOfNums {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter the number of values: ");
- int numValues = sc.nextInt();
- double sumOfValues = 0;
- for (int i = 1; i <= numValues; i++) {
- System.out.print("Enter value " + i + ": ");
- double value = sc.nextInt();
- sumOfValues += value;
- }
- double avg = sumOfValues / numValues;
- System.out.println("The average is: " + avg);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement