Question: please answer in Java..all excercises. /** * YOUR NAME GOES HERE * 4/7/2017 */ public class Chapter9a_FillInTheCode { public static void main(String[] args) { String
please answer in Java..all excercises. /** * YOUR NAME GOES HERE * 4/7/2017 */ public class Chapter9a_FillInTheCode { public static void main(String[] args) { String [][] geo = {{"MD", "NY", "NJ", "MA", "CA", "MI", "OR"}, {"Detroit", "Newark", "Boston", "Seattle"}}; // ------> exercise 9a1 // this code prints the element at row at index 1 and column at index 2 // your code goes here System.out.println("Done exercise 9a1. "); // ------> exercise 9a2 // this code prints all the states in the first row (the row at index 0) of array goe that start with an M. for (int col = 0; col < geo[0].length; col++) { // your code goes here } System.out.println("Done exercise 9a2. "); // ------> exercise 9a3 // this code prints all the cities in the second row (the row at index 1) of the array geo. for (int col = 0; col < geo[1].length; col++) { // your code goes here } System.out.println("Done exercise 9a3. "); // ------> exercise 9a4 // this code prints all the elements of the array geo. for (int row = 0; row < geo.length; row++) { // your code goes here } System.out.println("Done exercise 9a4. "); int [][] a = {{9, 6, 8, 10, 5}, {7, 6, 8, 9, 6}, {4, 8, 11, 5, 6}}; // ------> exercise 9a5 // this code calculates and prints the sum of all the elements in the array a. int sum = 0; for (int row = 0; row < a.length; row++) { // your code goes here } System.out.println("sum of all elements in array a = " + sum); System.out.println("Done exercise 9a5. "); // ------> exercise 9a6 // this code calculates and prints the number of times the value 8 appears in the array a. int numberOfEights = 0; for (int row = 0; row < a.length; row++) { // your code goes here } System.out.println("# of 8s in a = " + numberOfEights); System.out.println("Done exercise 9a6. "); // ------> exercise 9a7 // this code calculates and prints the number of times the value 6 appears in the second row // (i.e., the row whose index is 1) of array a. int numberOfSixes = 0; // your code goes here System.out.println("# of 6s in the second row = " + numberOfSixes); System.out.println("Done exercise 9a7. "); // ------> exercise 9a8 // this code calculates the sum of the elements in the third column (i.e, the column with index 2) of array a. int columnSum = 0; for (int row = 0; row < a.length; row++) { // your code goes here } System.out.println("sum of elements in the third column = " + columnSum); System.out.println("Done exercise 9a8. "); // ------> exercise 9a9 // this code calculates the sum of the elements in the second row (i.e, the row with index 1) of array a. int rowSum = 0; for (int col = 0; col < a[1].length; col++) { // your code goes here } System.out.println("sum of elements in the second row = " + rowSum); System.out.println("Done exercise 9a9. "); // ------> exercise 9a10 // this code calculates and prints totals per row of array a. for (int row = 0; row < a.length; row++) { // your code goes here System.out.println("sum of elements in row " + row + " = " + rowSum); } System.out.println("Done exercise 9a10. "); // ------> exercise 9a11 // this code finds and prints the largest value of array a. int maxValue = Integer.MIN_VALUE; for (int row = 0; row < a.length; row++) { // your code goes here } System.out.println("the largest value in array a = " + maxValue); System.out.println("Done exercise 9a11. "); // ------> exercise 9a12 // this code finds the "smallest" row of array a (the row with the smallest sum of the elements) // and prints the its index, its sum, and its elements System.out.println("Done exercise 9a12."); // ------> exercise 9a13 // this code creates a single dimensional array of boolean with the number of elements equal to the number // of rows in array a. Every element of the boolean array should be set to true if the sum of the elements // in the corresponding row in array a is greater than 35. // Prints the boolean array. System.out.println("Done exercise 9a13."); // ------> exercise 9a14 // this code sets to 0 all the elements of the even-numbered rows and sets to 1 all the elements of // the odd-numbered rows of array a. Prints all the elements of the updated array System.out.println("Done exercise 9a14."); } } Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
