You are given a skeleton of Program 2, answer questions a) and b) below. a) Complete Program 2 based on the question (i)

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

You are given a skeleton of Program 2, answer questions a) and b) below. a) Complete Program 2 based on the question (i)

Post by answerhappygod »

You Are Given A Skeleton Of Program 2 Answer Questions A And B Below A Complete Program 2 Based On The Question I 1
You Are Given A Skeleton Of Program 2 Answer Questions A And B Below A Complete Program 2 Based On The Question I 1 (74.28 KiB) Viewed 55 times
You are given a skeleton of Program 2, answer questions a) and b) below. a) Complete Program 2 based on the question (i) to (ix) in comments provided. // Program 2 import java.util.Scanner; class TlArray public void changeElement(int num) { num = num+5; } public void changeArray (int[] dArray){ for (int i=0; i<dArray.length; i=i+2) { dArray=dArray*3; } public class TestArray { public static void main(String[] args) { int size = 5; double [] datal = new double (size); 1/60) declare another integer array named data2 using initializer list and initialized with values: 8, 7, 6, 2, 8 and 5 {8,7,6,2,8,5}; //(ii) call method inputData() to assign values for datal //(ii) call method printArray() to display all values in datal 1/(iv) call to method isAscending() to check whether elements in datal is in ascending order System.out.println("Data is in ascending order"); else System.out.println("Data is not in ascending order"); TlArray t1= new TlArray(); //(v) call method changeElement() and pass the fourth element of array data2 //(vi) call method changeArray() and pass array data2

TlArray t1= new TIArray(); //(v) call method changeElement() and pass the fourth element of array data2 //(vi) call method changeArray() and pass array data2 } public static void inputData(double[] arr) { Scanner kb= new Scanner(System.in); System.out.println("Enter a series of " + arr.length + "numbers."); for (int i=0; i<arr.length; i++) { System.out.print("Enter number" + (i+1) + ":"); 1/(vii)assign input to elements of datal public static boolean isAscending( double [] array) { boolean inOrder = true; for (int j=0; j<array.length-1; j++) 1/(viii) compare elements of the array if inOrder = false; } return inOrder; } public static void printArray(double [] array){ System.out.println("\nThe content of array datal:"); // (ix) use enhanced for-loop to print all elements of the array for item : System.out.println } b) What is the content of array data2 after Program 2 is executed? Content of array data2[] after execution of Program 2:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply