Write a program to determine the minimum element in an array of ten elements. The program should have the following:
1. Class Name as ArrayProcessing. The main method should create an array of size 10
2. There should be two methods besides the main method in the class namely inputArray and MinimumElement
3. InputArray method should assign the ten elements in the array. Use scanner to input these elements. The array of 10 numbers in the method "InputArray" should be passed as the argument and should return these values.
3.Minimum Element method should find the minimum element in the array. The array of 10 numbers in the method "Array Processing" should be passed as the argument and should return the minimum values.
(use Dr.Java and please i have 30 minutes help me)
Code
import java.util.Scanner;
public class ArrayProcessing {
public static void main(String[] args) {
int intArray[]=new int [10];
inputArray(intArray);
int
min=MinimumElement(intArray);
System.out.println("\nMinimum
element from the array is: "+min);
}
private static int MinimumElement(int[] intArray)
{
int min=intArray[0];
for(int
i=1;i<intArray.length;i++)
if(min>intArray[i])
min=intArray[i];
return min;
}
private static void inputArray(int[] intArray)
{
Scanner scnr=new
Scanner(System.in);
for(int
i=0;i<intArray.length;i++)
{
System.out.print("Enter "+(i+1)+" element in array: ");
intArray[i]=scnr.nextInt();
}
}
}
output
If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.
Get Answers For Free
Most questions answered within 1 hours.