Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE COMPLETE THE LAB FOLLOWING THE GIVEN GUIDELINES (MAKE SURE IT OUTPUTS CORRECTLY /*** * * Complete the static methods below to perform some basic

PLEASE COMPLETE THE LAB FOLLOWING THE GIVEN GUIDELINES (MAKE SURE IT OUTPUTS CORRECTLY

/*** * * Complete the static methods below to perform some basic array tasks * * Below is the expected output * * ---array example 1--- * 4, 5, 9, 7, 3, 4, 8 * The largest value is: 9 * The smallest value is: 3 * In order: false * * ---array example 2--- * 24, 87, 96, 102, 874, 941 * reverse order: 941, 874, 102, 96, 87, 24 * In order: false * * ---array example 3--- * 2, 6, 8, 9 * 1, 3, 7, 9, 10 * merged array: 1, 2, 3, 6, 7, 8, 9, 9, 10 * In order: true * ****/ public class ArrayBasics { /*** <<< CODE NOT COMPLETE >>> * prints out an array of any size ***/ public static void print(int[] a) { // <<< COMPLETE THE CODE >>> } /*** <<< CODE NOT COMPLETE >>> * returns the largest integer in an array ***/ public static int max(int[] a) { // <<< COMPLETE THE CODE >>> }

/*** <<< CODE NOT COMPLETE >>> * returns the smallest integer in an array ***/ public static int min(int[] a) { // <<< COMPLETE THE CODE >>> } /*** <<< CODE NOT COMPLETE >>> * returns boolean true if the array is in sorted order * else returns false ***/ public static boolean inOrder(int[] a) { // <<< COMPLETE THE CODE >>> }

/*** <<< CODE NOT COMPLETE >>> * reverses the order of the elements in the array ***/ public static void reverse(int[] a) { // <<< COMPLETE THE CODE >>> } /*** <<< CODE NOT COMPLETE >>> * merges two sorted arrays into 1 new array, maintains the sorted order ***/ public static int[] merge(int[] a, int[] b) { // <<< COMPLETE THE CODE >>> }

/*** * The main method is complete. */

public static void main(String[] args) { System.out.println(" ---array example 1---"); int num1[] = {4,5,9,7,3,4,8}; print(num1); System.out.println("The largest value is: " + max(num1)); System.out.println("The smallest value is: " + min(num1)); System.out.println("In order: " + inOrder(num1)); System.out.println(" ---array example 2---"); int num2[] = {24,87,96,102,874,941}; print(num2); System.out.print("reverse order: "); reverse(num2); print(num2); System.out.println("In order: " + inOrder(num2)); System.out.println(" ---array example 3---"); int num3[] = {2,6,8,9}; int num4[] = {1,3,7,9,10}; print(num3); print(num4); System.out.print("merged array: "); int merged[] = merge(num3,num4); print(merged); System.out.println("In order: " + inOrder(num3));

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions