Advertisement
Guest User

average ][ Dev-Point

a guest
Nov 5th, 2019
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Avrgg{
  3.  
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner sc = new Scanner(System.in);
  7.        
  8.         double[] nums = new double[5];
  9.         int i = 0;
  10.         double summ = 0;
  11.         while(i<5) {
  12.             System.out.print("Enter num "+i+" > " );
  13.             double x = sc.nextDouble();
  14.             nums[i] = x;
  15.             summ += x;
  16.            
  17.             i++;
  18.         }
  19.         for(int o = 0 ; o<5;o++) {
  20.             System.out.print(nums[o]+ " " );
  21.            
  22.            
  23.         }
  24.         System.out.println("][ average is : "+summ/5);
  25.     }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement