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

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

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

Post by answerhappygod »

Si Malaysia You Are Given A Skeleton Of Program 2 Answer Questions A And B Below A Complete Program 2 Based On The 1
Si Malaysia You Are Given A Skeleton Of Program 2 Answer Questions A And B Below A Complete Program 2 Based On The 1 (192.19 KiB) Viewed 35 times
Si Malaysia You Are Given A Skeleton Of Program 2 Answer Questions A And B Below A Complete Program 2 Based On The 2
Si Malaysia You Are Given A Skeleton Of Program 2 Answer Questions A And B Below A Complete Program 2 Based On The 2 (197.18 KiB) Viewed 35 times
SI MALAYSIA 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 ll datal = new double (size]; 1/6) 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 //(iv)call to method isAscending to check whether elements in datal is in ascending order if

System.out.println("Data is in ascending order"); else System.out.println("Data is not in ascending order"); TIArray t1= new TIArray(); 1/(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) + " "); //(vii) assign input to elements of datal } public static boolean isAscending( double [] array) { boolean in order = true; for (int j=0; j<array length-1; j++) { 1/(viil) compare elements of the array if inOrder = false; } return inOrder;

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