Complete the folllowing program : answer = blank >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

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

Complete the folllowing program : answer = blank >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Post by answerhappygod »

Complete the folllowing program :
answer = blank
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import java.util.Scanner;
class T1Array
{
public void changeElement (double
num) {
num = num*num;
}
public void changeArray (double[]
dArray){
for
(int i=0; i<dArray.length; i=i+3){
dArray= dArray*2;
}
}
}
public class TestArray {
public static void main (String[] args) {
int size = 5;
int [] data2= new int
[size];
//(i) declare another array
named data1 using initializer list and
initialized with values : 2.5, 5.0, 4.2, 1.0, 6.1 and
3.0
Answer [] Answer Answer{2.5, 5.0,
4.2, 1.0, 6.1, 3.0};
//(ii)call method inputData() to
assign values for data2
Answer;
;
//(iii) call
method printArray() to display all
values in data2
Answer;
//(iv)call to
method isAscending() to check whether
elements in data2 is in ascending
order
if ( Answer)
System.out.println( " Data is in
ascending order" );
else
System.out.println("Data is not in ascending
order" );
T1Array tA= new T1Array();
//(v) call
method changeElement() and pass the
third element of array data1
Answer;
//(vi) call method changeArray() and
pass array data1
Answer;
}
public static void inputData(int [] 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 data2
}
}
public static boolean isAscending( int
[] array ) {
boolean inOrder = true;
for (int i=0;
i<array.length-1; i++ )
{
//(viii) compare elements of
the array
if
(Answer Answer Answer )
inOrder = false;
}
return inOrder;
}
public static void printArray(int [] arr
){
System.out.println ("\nThe content of array
data2:");
// (ix) use enhanced for-loop to print all elements of the
array
for (Answer val :Answer)
System.out.println (Answer);
}
}
b) What is the content of
array data1 after Program 2 is
executed?
Content of array data1[] after execution of
Program
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply