Question

1.) Using the following declarations and a member of the Array class, int [ ] bArray...

1.)

Using the following declarations and a member of the Array class,
int [ ] bArray = new int [10];
int location;
Using a method in the Array class, write a statement that would order the values in the bArray array in ascending order.

___________________

HINT: You must write the full statement which includes a call to a method in the Array class.

2.)

Using the following declarations and a member of the Array class,
int [ ] bArray = new int [10];
int location;
Using a method of the Array class, write an assignment statement that would return the index in the bArray array where 14 is stored.

__________________________

HINT: You must write the full assignment statement which includes a call to a method in the Array class.

3.)

Using just the following declarations,
int counter = 0;
int val;
int [ ] bArray = new int [10];
Write the body of the for loop that could be used to increment each element in bArray by 5. The for loop might loop like:

for (counter = 0; counter < bArray.Length; counter++)

__________________

HINT: You are not writing the control structure, just the body of the loop where counter will be the index used with the bArray.

4.)

Using the following declarations,
int counter = 0;
double val;
double [ ] bArray = new double [10];
To display the contents of bArray, show what the foreach loop control construct would resemble.

______________

HINT: Write the first line of the loop - the line that has the foreach on it. You are not writing the body...just the loop control statement.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
1)
Arrays.sort(bArray);
                
2)
location = Arrays.binarySearch(bArray, 14);

3)
bArray[counter] += 5;

4)
for(double a: bArray)
**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.

Add a comment
Know the answer?
Add Answer to:
1.) Using the following declarations and a member of the Array class, int [ ] bArray...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 1 Using the following declarations and a member of the Array class, int [ ]...

    QUESTION 1 Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would change the order of the elements in the bArray array. The contents of the first cell should hold what was in the last cell. The second cell should hold what was in the next to last cell. __________________________ HINT: You must write the full statement...

  • Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array...

    Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array double[10]; c. charl charArray "Computer Science"; None of the above Analyze the following code: class Test public static void main(Stringl] args) System.out.println(xMethod(10); public static int xMethod(int n) System.out.println("int"); return n; public static long xMethod(long n) System.out.,println("long"); return n The program displays int followed by 10 The program displays long followed by 10. The program does not compile. None of the above. tions 3-4 are...

  • Using Java write a program that performs the following: 1. Define a class that contains an...

    Using Java write a program that performs the following: 1. Define a class that contains an array of type int as a data member. 2. Define a constructor that creates an array of 1024 elements and assigns it to the class data member. The constructor shall populate the elements with random numbers ranging in value from 1 to 1024. 3. Define and implement a search() method that take a parameter of type int and returns the index location if the...

  • Develop a set of static methods in a class called Array Tools that perform the functions...

    Develop a set of static methods in a class called Array Tools that perform the functions below, and overload the methods for the specified types: Description Returns the minimum value stored in an array. Array Tools Method char minimum char array[]) int minimum( int array[] ) double minimum double arrayll ) char maximum char array() ) int maximum( int array[] ) double maximum( double array[] ) Returns the maximum value stored in an array. int minimumAt( char array()) int minimumAt(...

  • In the "Go" button add 15 random numbers in the array using a random number generator....

    In the "Go" button add 15 random numbers in the array using a random number generator. Remove the call to "SetToZero" and the code following. Remove the "SetToZero" method. Add Access Keys of your choice Assign an accept button Assign cancel button (Exit) Add a Button "Find Max" Write an appropriately named method that Accepts the array Finds the largest int and returns the value "Find Max" button click Calls above method Opens a MessageBox to display the returned value...

  • CREDITUU NAME: (8) Given the following declarations: int *pt: int size; a) Write the one statement...

    CREDITUU NAME: (8) Given the following declarations: int *pt: int size; a) Write the one statement that will dynamically allocate an integer array of size size WHICH YOU WILL WRITE TO GET USER INPUT FROM THE CONSOLE using the declarations above. b) Write the one statement that would delete the dynamically allocated array.

  • Assuming you have the following ordered-array class definition: class ordered_array { public: ordered_array(int c) { data...

    Assuming you have the following ordered-array class definition: class ordered_array { public: ordered_array(int c) { data = new int[c]; cp = c; sz = 0; } ... private: int sz, cp; // Current size, total capacity int* data = nullptr; }; Suppose that ordered_arrays can contain duplicates. Implement a method remove_duplicates(e)which takes an element e and removes it and any duplicates of it. (Note that e is the actual value to be removed, not its index in the array.) If...

  • JAVA I. Using the Event Class created previously, create an array of objects;        II. Demonstrate...

    JAVA I. Using the Event Class created previously, create an array of objects;        II. Demonstrate passing array reference to a method;        III. Demonstrate creating array of objects that prints out only x 0.0 for all objects. PROJECT 5C - ARRAYS Create a new file called " EventArray5C". There are some "challenging" directions in this project. . 1.Prepare a document box (tell me that task(s) the application is to accomplish, how it will accomplish the tasks, the author of...

  • In Java, write a class Grade with following member variables and method: int midtermExam, int finalExam:...

    In Java, write a class Grade with following member variables and method: int midtermExam, int finalExam: represent the scores of midterm and final exams respectively. The maximum score for each exam is 100. double getOverallScore(): returns the overall score calculated as follows: 40% midterm and 60% final. Write another class Grade180 that is a subclass of Grade and has the following member variables and method: int midtermExam, int finalExam: inherited from Grade super class. int hw1, int hw2, int project1,...

  • Array Class Assignment

    This is a two-part assignment. It is better to submit the files for both parts when you are done than to submit part 1 first and part 2 later.In the Array.h file includes the class definition and member functions implementations.PART 1Write And Test An Array Class [Array.TestDriver.cpp] Write a data structures class. The resulting class can be used in any program in place of a C++ array, in case you want the advantages of range safety and built-in size tracking.Requirements....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT