004-009-006

Array and Method: Maximum Value Search

Medium

Problem Description

array and method: Maximum Value Search

In this problem, you will create a program that reads an integer array from standard input, implements a findMax method to search for the maximum value, and displays the result.

Learning Objective: Create a method that receives an array as argument and functionalize array operations

Overview

Create a method findMax that receives an integer array as argument and returns the maximum value in the array.

Input Format

N
a1 a2 ... aN
  • Line 1: number of elements N (1 ≤ N ≤ 100)
  • Line 2: N space-separated integers

Specifications

  • Method name: findMax
  • Parameter: integer array int[] numbers
  • Return value: maximum value in array (int type)

Output Format

Maximum value: [maximum]

Hint: Use the first element as initial value and compare with all elements.

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up