Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

quiz

import java.util.scanner ;
public class HelloWorld{

     public static void main(String []args){
        System.out.println("Hello World");
    Scanner scan = new Scanner (System.in);
    System.out.println("enter array length :"  );
    int x = scan.nextInt(); 
    double array[]= new double[x];
    for (i=0; i<x ; i++)
    {
        System.out.println ("enter" + (i+1)+ "elements to store in array :");
        array[i]= scan.nextDouble();
    }
     System.out.println ("elements of array are:");
    for  (i=0; i<x ; i++)
    {
         System.out.println(array[i]+" " );
    }
    System.out.println();
    
    double sum= 0, avg= 0;
        for  (i=0; i<x ; i++)
        {
            sum+=array[i];
        }
    avg= sum/x ;
    
     System.out.println("the sum is :" + sum);
     System.out.println("the avg is :" + avg);
    
    double min=0 ;
    for (i=0; i<x ; i++)
    {
        if (min> array[i])
        {
            min = array[i];
        }
        }
        
        double max=0 ;
    for (i=0; i<x ; i++)
    {
        if (max< array[i])
        {
            max = array[i];
        }
        }
        
     }
}
    
    
    
    
    
    
     }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.