Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Qn1) Determine whether the following array declarations are valid. If a declaration is invalid, give a correct declaration. a. int[75] list; b. int size; double[]

Qn1) Determine whether the following array declarations are valid. If a declaration is invalid, give a correct declaration. a. int[75] list;

b. int size; double[] list = new double[size];

c. int[] test = new int[-10];

d. double[] sales = new double[40.5];

e. scores double = new double[50]; Qn2 a. What would be a valid range for the index of an array of size 50? Write Java statements that do the following : b. Declare an array alpha of 15 elements of type int.

c. Output the value of the tenth element of the array alpha.

d. Set the value of the fth element of the array alpha to 35.

e. Set the value of the ninth element of the array alpha to the sum of the sixth and thirteenth elements of the array alpha.

f. Set the value of the fourth element of the array alpha to three times the value of the eighth element, minus 57.

g. Output alpha so that ve elements per line are printed. Qn3 Write Java statements for performing the following tasks with a 2D array named values that has 20 rows and 30 columns. a. Declare the array values.

b. Fill all entries with 0.

c. Fill elements alternately with 0s and 1s in a checkerboard pattern.

d. Fill only the elements at the top and bottom row with zeroes.

e. Compute the sum of all elements.

f. Print the array in tabular form

(Hint: you could use the method System.out.printf()).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions