Write a Java program which declares and populates an array with some values (at least 5 values). Then it should call a method passing it the array. The method should modify the array values using a loop. Lastly, after the program calls the method, it should display the modified array contents to the console.
Added by Katherine P.
Close
Step 1
Declare and populate an array with some values: ```java int[] array = {1, 2, 3, 4, 5}; ``` Show more…
Show all steps
Your feedback will help us improve your experience
Supreeta N and 97 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Write a Java program that declares an array of size 10, using a constant for the size. Then, using a loop prompt the user to enter 10 floating point values and assign those values to the array. Display the contents using a for loop to go through the array and print out the contents until the end of the array has been reached.
John B.
Write a program with a method that returns an array. The method should accept as input a comma-delimited string with three values from a user. The array should store each value in a different element. Use try...catch error handling and print any failure messages, or print success from within the method if the execution is successful (see Chapter 13 in the text). Call the method from the main method of the program to demonstrate its functionality by looping through the array and printing the individual values.
Akash M.
Write a Java program that reads 20 integer numbers from the user using a loop. The program should find and display the largest number, the smallest number, and the average of the 20 numbers entered. You should not use arrays. You should have comments in your code. Run the program and take screenshots. Submit your Java code file and the screenshots.
Cora M.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD