Write Program Uses Array Doubles Initialized Whatever Values Wish Write Methods Calculate Q43903176
Write a program that uses an array of doubles initialized towhatever values you wish. Write methods to calculate and return theminimum and a method to calculate and return the maximum value inthe array. You must write YOUR ORIGINAL methods for minimum andmaximum. You MAY NOT use Math class methods or other librarymethods.
Write an additional method that accepts the array as a parameterand then creates and returns a new array with all the same valuesas the original plus 10. (num +=10)
So far I have:
public static void main (String[] args)
{
Scanner scan = new Scanner (System.in);
//making an array
double myArray[];
myArray = new double[5];
System.out.println (“Enter numbers:”);
//putting in a numbers in an array
for (int a = 0; a < 5; a++)
{
myArray[a] = scan.nextDouble();
}
//print the array
for (int a = 0; a < 5; a++)
{
System.out.print (myArray[a] + ” “);
}
System.out.println();
System.out.println (“The Min value in the array is: ” +findtheMinimum(myArray));
System.out.println();
System.out.println (“The Max value in the array is: ” +findTheMaximum(myArray));
System.out.println();
System.out.println (“This is the new array: ” +addTen(myArray));
}
//Find the minimum number
public static double findtheMinimum (double[] myArray)
{
double min = myArray[0];
for (int a = 1; a < 5;a++)
{
if( myArray[a] < min)
{
min = myArray[a];
}
}
return min;
}
//Find the maximum number
public static double findTheMaximum (double[] myArray)
{
double max = myArray[0];
for (int a = 1; a < 5;a++)
{
if( myArray[a] > max)
{
max = myArray[a];
}
}
return max;
}
public static double addTen (double[] myArray)
{
double myArray2[];
myArray2 = new double[5];
for (int a = 0; a < 5; a++)
{
myArray2[a] = myArray[a];
}
return myArray;
}
}
The add ten portion won’t work. Please help.
Expert Answer
Answer to Write a program that uses an array of doubles initialized to whatever values you wish. Write methods to calculate and re…
OR