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

Write a java program to satisfy all requirements... Receive and store the 10 num

ID: 3541662 • Letter: W

Question

Write a java program to satisfy all requirements... Receive and store the 10 numbers in an array Find the Min, Max and Sum of the 10 numbers Use a method to receive the 10 numbers and store in an array Use a method to return the Min of the 10 numbers Use a method to return the Max of the 10 numbers Use a method to return the Sum of the 10 numbers Write a java program to satisfy all requirements... Receive and store the 10 numbers in an array Find the Min, Max and Sum of the 10 numbers Use a method to receive the 10 numbers and store in an array Use a method to return the Min of the 10 numbers Use a method to return the Max of the 10 numbers Use a method to return the Sum of the 10 numbers

Explanation / Answer

Code


import java.util.Arrays;

import java.util.Scanner;


public class ArrayOfNumbers {

static int[] numbersArray = new int[10];

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.println("Enter the all 10 numbers one by one");

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

int numberTobeInput = scanner.nextInt();

storeIntoArray(numberTobeInput, i);

}

System.out.println("All elements in the array are added:");

System.out.println("Elements of the array are: ");

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

System.out.println(numbersArray[i]);

}

int minimum = returnMinimum(numbersArray);

System.out.println("Minimum number of the array is :"+minimum);

int maximum = returnMaximum(numbersArray);

System.out.println("Minimum number of the array is :"+maximum);

int sum = getSumOfValues(numbersArray);

System.out.println("Sum of all the elements of the array is :"+sum);

}

// Use a method to receive the 10 numbers and store in an array

public static void storeIntoArray(int number, int i){

numbersArray[i] = number;

}

//Use a method to return the Min of the 10 numbers

public static int returnMinimum(int[] array){

Arrays.sort(array);

return array[0];

}

//Use a method to return the Max of the 10 numbers

public static int returnMaximum(int[] array){

Arrays.sort(array);

return array[array.length-1];

}

//Use a method to return the Sum of the 10 numbers

public static int getSumOfValues(int[] array){

int sum = 0;

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

sum += array[i];

}

return sum;

}

}

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