Зміст курсу
Java Extended
Java Extended
Find Maximum and Minimum in Array Challenge
Завдання
Your task is to write two methods: one to find the maximum value and one to find the minimum value in the array.
- In the
findMax
method, initialize themax
variable with the first element of the array. - In the for loop, compare the current element with
max
. - If the current element is greater, update
max
with the current element. - Return the value of the
max
variable. - In the
findMin
method, initialize themin
variable with the first element of the array. - In the for loop, compare the current element with
min
. - If the current element is smaller, update
min
with the current element. - Return the value of the
min
variable. - In the
main
method, call thefindMax
method with the correct parameter, pass thenumbers
array into it, and assign the result to themax
variable. - In the
main
method, call thefindMin
method with the correct parameter, pass thenumbers
array into it, and assign the result to themin
variable.
Дякуємо за ваш відгук!
Find Maximum and Minimum in Array Challenge
Завдання
Your task is to write two methods: one to find the maximum value and one to find the minimum value in the array.
- In the
findMax
method, initialize themax
variable with the first element of the array. - In the for loop, compare the current element with
max
. - If the current element is greater, update
max
with the current element. - Return the value of the
max
variable. - In the
findMin
method, initialize themin
variable with the first element of the array. - In the for loop, compare the current element with
min
. - If the current element is smaller, update
min
with the current element. - Return the value of the
min
variable. - In the
main
method, call thefindMax
method with the correct parameter, pass thenumbers
array into it, and assign the result to themax
variable. - In the
main
method, call thefindMin
method with the correct parameter, pass thenumbers
array into it, and assign the result to themin
variable.
Дякуємо за ваш відгук!
Find Maximum and Minimum in Array Challenge
Завдання
Your task is to write two methods: one to find the maximum value and one to find the minimum value in the array.
- In the
findMax
method, initialize themax
variable with the first element of the array. - In the for loop, compare the current element with
max
. - If the current element is greater, update
max
with the current element. - Return the value of the
max
variable. - In the
findMin
method, initialize themin
variable with the first element of the array. - In the for loop, compare the current element with
min
. - If the current element is smaller, update
min
with the current element. - Return the value of the
min
variable. - In the
main
method, call thefindMax
method with the correct parameter, pass thenumbers
array into it, and assign the result to themax
variable. - In the
main
method, call thefindMin
method with the correct parameter, pass thenumbers
array into it, and assign the result to themin
variable.
Дякуємо за ваш відгук!
Завдання
Your task is to write two methods: one to find the maximum value and one to find the minimum value in the array.
- In the
findMax
method, initialize themax
variable with the first element of the array. - In the for loop, compare the current element with
max
. - If the current element is greater, update
max
with the current element. - Return the value of the
max
variable. - In the
findMin
method, initialize themin
variable with the first element of the array. - In the for loop, compare the current element with
min
. - If the current element is smaller, update
min
with the current element. - Return the value of the
min
variable. - In the
main
method, call thefindMax
method with the correct parameter, pass thenumbers
array into it, and assign the result to themax
variable. - In the
main
method, call thefindMin
method with the correct parameter, pass thenumbers
array into it, and assign the result to themin
variable.