can anyone help me to slove this 4 questions? N Assignment 7-Array String alue o
ID: 3862289 • Letter: C
Question
can anyone help me to slove this 4 questions?
Explanation / Answer
5)
Ex5MinMax.java
import java.util.Arrays;
public class Ex5MinMax {
static int max;
static int min;
public static void main(String[] args) {
int[] my_array={25,10,55,65,36,92,77,8,13,79};
max_min(my_array);
System.out.println("Original Array:"+Arrays.toString(my_array));
System.out.println("Maximum Value for the above Array:"+max);
System.out.println("Minimum Value for the above Array:"+min);
}
private static void max_min(int[] my_array) {
min=my_array[0];
max=my_array[0];
for(int i=0;i<my_array.length;i++)
{
if(min>my_array[i])
min=my_array[i];
if(max<my_array[i])
max=my_array[i];
}
}
}
______________________
Output:
Original Array:[25, 10, 55, 65, 36, 92, 77, 8, 13, 79]
Maximum Value for the above Array:92
Minimum Value for the above Array:8
_________________
6)
Ex6Reverse.java
import java.util.Arrays;
public class Ex6Reverse {
public static void main(String[] args) {
int i, j;
int[] my_array1 = { 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,2018, 2019 };
System.out.println("Original Array :" + Arrays.toString(my_array1));
i = 0;
j = my_array1.length - 1;
int temp;
while (i < j) {
temp = my_array1[i];
my_array1[i] = my_array1[j];
my_array1[j] = temp;
i++;
j--;
}
System.out.println("Reverse Array :" + Arrays.toString(my_array1));
}
}
___________________
Output:
Original Array :[2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019]
Reverse Array :[2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010]
_____________________
7) I will do rem also
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.