Ask Data Structure Expert

1. Assume the instruction: boolean [] myBoolean = new boolean[10];

a. What is the name of the array variable?
b. What type of values the above array is for?
c. What is the range of valid indexes values for the above array?
d. What will be the value of myBoolean.length?
2. Using the following segment code

for(int i = 1; i <= 5; i++)

{

System.out.println(i * 5);

}

a) What is the output for this code?
b) Augment the code to output also the squares of each of the numbers 1-5.
c) Modify the code to print only the when i is even

3. Write a segment of code to traverse (go through each element of) an array of intergers, or size 10, called int_array and print out each element to the console

4. Write a segment code to sum and print the average of 100 random numbers between 1 and 6.

5. Write a segment of code to traverse (go through each element of) an array of integers, or size 10, called int_array and print out each element to the console.

6. Explain the difference between the control variables in a while loop and a for loop

7. a. What is the name of the variable controlling the while loop?

b. In which line is updated the variable controlling the loop?

c. What is the initial value of the variable controlling the while loop?

d. What is the value of the variable controlling the loop in line 18?

8. If a variable controlling a while loop is not updated inside of the loop then, the loop goes for ever (infinite loop)

Example:
int control = 1;
While (control != 10){
System.out.println( "control " + (control + 2));
}
a. This is an infinite loop; fix it
b. Modify the above code to print only 1 3 5 7 9

9. Write a segment code for the following:( do not worry for the syntax) Set a loop to request a phrase from the keyboard. If the phrase contains the word "loop",  the boolean variable myFlag is set to false to stop the loop.

10. From the given loop answer the following questions:

a. What is the value of the variable controlling the loop?
b. How is the variable mutated or modified to reach the value to end the loop?
c. Is the statement mutating or modifying the variable inside of the body of the loop?
d. When the loops end; What is the value of the variable controlling the loop:

11. Define the data structure array. Include uses; what represent the name of the array; importance of the index value; naming of the variables bundle within the array.

12. Describe how do you declare an array

13. How the arrays in java are initialized?

14. Describe how do you print the content of an array

15. Describe how do you traverse an array

16. Explain the code below: what is the input?;output? Transformed data?

17. What is the problem in this segment code?

18. Write a segment code to request the user a number from 1 to 15; then print a pyramid to that number. Example if the user input 8, the output is the following
1
12
123
1234
12345
123456
1234567
12345678

19. Using the following code answer the questions:

for (int i = 0; i < n; i++)

{ a[i] = Math.random(); }

a. What is the name of the array?

b. What is the variable indexing the array?

c. What is the range of the indexing variable?

20. Using the following code answer the questions:

for (int i = 0; i < n; i++)

{ System.out.println("a "+ i + ", " + a[i]); }

a. What ‘the statement in the loop' is printing?

Data Structure, Computer Science

  • Category:- Data Structure
  • Reference No.:- M91330218
  • Price:- $35

Guranteed 24 Hours Delivery, In Price:- $35

Have any Question?


Related Questions in Data Structure

Data Communication Delivering Information anywhere

Topic: Data Communication Delivering Information anywhere. Write a 9-12 pages paper in which you: Present an overview of the origin and history of the concept. Describe the current use of and attitude toward the concept. ...

Problem regarding the management program

Problem: Looks like its just adding a save and load feature to the same file you sent me for python 3.5 Until now, you have had to leave your team management program running on your computer indefinitely since you did no ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As