Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assignment pdt-Adobe Acobat ow Hel Document Lab 6: (1) Go to http://ideone.com/

ID: 3604029 • Letter: A

Question

Assignment pdt-Adobe Acobat ow Hel Document Lab 6: (1) Go to http://ideone.com/ to run the following Ada sample code. (2) Refer to this sample code, write an Ada code that read ten integers from stdin, and find the largest, smallest, average, and sorting from small to large, and display on stdout. With Ada.Text_IO; Use Ada. Text I0; With Ada. Integer Text 10; Use Ada. Integer Text IO; procedure Arrl is Array subscripts 1 to 5 A: array(1.5) of Integer; I: Integer sum: integer begin sum: Read em in for I in 1..5 loop Put(" "); Get (A(I)) end loop: here to search DOLL F7 FS 84 7 8 2 3 4 5 6

Explanation / Answer

/* package whatever; // don't place package name! */

import java.util.*;

import java.lang.*;

import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */

class Ideone

{

public static void main (String[] args) throws java.lang.Exception

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter 10 Array integer elements: ");

int[] arr=new int[10];

for(int i=0;i<arr.length;i++){

arr[i]=sc.nextInt();

}

Arrays.sort(arr);

System.out.println("Smallest Element: "+arr[0]);

System.out.println("Largest Element: "+arr[arr.length-1]);

double avg=0;

int sum=0;

System.out.println("Array Elements After sorting are:");

for(int j=0;j<arr.length;j++){

System.out.print(arr[j]+" ");

sum=sum+arr[j];

}

avg=sum/arr.length;

System.out.println(" Average of Array elements : "+avg);

}

}

/* output:-

Enter 10 Array integer elements:

32 12 56 34 87 93 06 03 63 31

Smallest Element: 3

Largest Element: 93

Array Elements After sorting are:

3 6 12 31 32 34 56 63 87 93

Average of Array elements : 41.0

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote