Java : Introduction To Prob...-MyProgrammingLab
15th Edition
ISBN: 9780133860771
Author: SAVITCH
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 7.5, Problem 28STQ
What output is produced by the following code?
int[][] testArray = new int[3][4];
for (int row = 0; row < testArray.length; row++)
for (int col = 0;
col < testArray[row].length; col++)
testArray[row][col] = col;
for (int row = 0; row < testArray.length; row++)
{
for (int col = 0;
col < testArray[row].length; col++)
System.out.print(testArray[row][col] + " ");
system.out.println();
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a Java Console application in which you initialize an arraylist with 10 String values. For example, 10 colour names, or fruit names, or veg names, or car names, etc. Display all the values in the list in a neat tabular format. Randomly select a value from the array. Now allow the user 3 chances to guess the value. After the first incorrect guess provide the user with a clue: the first letter of the randomly selected word. After the second incorrect guess provide the user with another clue: the number of letters in the word. Once the user correctly guesses the word, remove that word from the list. Display the number of items in the list. The user must have the option to play again.
[in java]
Write a loop that computes the average of an array of integers [2, 5, 6, 7,9] called avgNum that has been previously declared and initialized. Store the result in a variable of type integer called iAvg that has been previously declared and initialized to zero.
Consider the code snippet below:
int scores[10] = { 7, 4, 10, 5, 1};
What code below is an equivalent way to write (scores + 1)?
A) We don't know what will be output, this is out of bounds for the array
B) *scores + 1
C) scores[1]
D) 4
E) &(scores[1])
Chapter 7 Solutions
Java : Introduction To Prob...-MyProgrammingLab
Ch. 7.1 - What output will be produced by the following...Ch. 7.1 - What output will be produced by the following...Ch. 7.1 - What output will be produced by the following...Ch. 7.1 - Consider the following array: int [] a = new...Ch. 7.1 - What is wrong with the following code to...Ch. 7.1 - Write a complete Java program that reads 20 values...Ch. 7.2 - Write some Java code that will declare an array...Ch. 7.2 - Rewrite the method displayResults of the program...Ch. 7.2 - What output will be produced by the following...Ch. 7.2 - Give the definition of a static method called...
Ch. 7.2 - Give the definition of a static method called...Ch. 7.2 - Prob. 12STQCh. 7.2 - The following method compiles and executes but...Ch. 7.2 - Suppose that we add the following method to the...Ch. 7.3 - Prob. 15STQCh. 7.3 - Replace the last loop in Listing 7.8 with a loop...Ch. 7.3 - Suppose a is an array of values of type double....Ch. 7.3 - Suppose a is an array of values of type double...Ch. 7.3 - Prob. 19STQCh. 7.3 - Consider the partially filled array a from...Ch. 7.3 - Repeat the previous question, but this time assume...Ch. 7.3 - Write an accessor method getEntryArray for the...Ch. 7.4 - Prob. 23STQCh. 7.4 - Write the invocation of the method selectionSort...Ch. 7.4 - How would you need to change the method...Ch. 7.4 - How would you need to change the method...Ch. 7.4 - Consider an array b of int values in which a value...Ch. 7.5 - What output is produced by the following code?...Ch. 7.5 - Revise the method showTable in Listing 7.13 so...Ch. 7.5 - Write code that will fill the following array a...Ch. 7.5 - Write a void method called display such that the...Ch. 7.6 - Prob. 33STQCh. 7 - Write a program in a class NumberAboveAverage that...Ch. 7 - Write a program in a class CountFamiles that...Ch. 7 - Write a program in a class CountPoor that counts...Ch. 7 - Write a program in a class FlowerCounter that...Ch. 7 - Write a program in a class characterFrequency that...Ch. 7 - Create a class Ledger that will record the sales...Ch. 7 - Define the following methods for the class Ledger,...Ch. 7 - Write a static method isStrictlyIncreasing (double...Ch. 7 - Write a static method removeDuplicates(Character[]...Ch. 7 - Write a static method remove {int v, int [] in}...Ch. 7 - Suppose that we are selling boxes of candy for a...Ch. 7 - Create a class polynomial that is used to evaluate...Ch. 7 - Write a method beyond LastEntry (position) for the...Ch. 7 - Revise the class OneWayNoRepeatsList, as given in...Ch. 7 - Write a static method for selection sort that will...Ch. 7 - Overload the method selectionSort in Listing 7.10...Ch. 7 - Revise the method selectionSort that appears in...Ch. 7 - Prob. 18ECh. 7 - Write a sequential search of an array of integers,...Ch. 7 - Write a static method findFigure (picture,...Ch. 7 - Write a static method blur (double [] [] picture)...Ch. 7 - Write a program that reads integers, one per line,...Ch. 7 - The following code creates a small phone book. An...Ch. 7 - Write the method rotateRight that takes an array...Ch. 7 - The following code creates a ragged 2D array. The...Ch. 7 - Write a program that will read a line of text that...Ch. 7 - Prob. 2PPCh. 7 - Add a method bubbleSort to the class ArraySorter,...Ch. 7 - Add a method insertionSort to the class...Ch. 7 - The class TimeBook in Listing 7.14 is not really...Ch. 7 - Define a class called TicTacToe. An object of type...Ch. 7 - Repeat Programming Project 10 from Chapter 5 but...Ch. 7 - Prob. 8PPCh. 7 - Write a GUI application that displays a picture of...Ch. 7 - ELIZA was a program written in 1966 that parodied...Ch. 7 - Prob. 11PPCh. 7 - Create a GUI application that draws the following...Ch. 7 - Practice Program 2 used two arrays to implement a...Ch. 7 - Practice Program 5.4 asked you to define Trivia...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Examine the following function header, then write a statement that calls the function, passing 12 as an argumen...
Starting Out with Python (4th Edition)
Rock, Paper, Scissors Game Design a program that lets the user play the game of Rock, Paper, Scissors against t...
Starting Out with Programming Logic and Design (4th Edition)
Look at the following declaration: enum Flower { ROSE, DAISY, PETUNIA }; In memory, what value will be stored f...
Starting Out with C++ from Control Structures to Objects (8th Edition)
Can you assign new int[50], new Integer [50], new String [50], or new Object [50] into a variable of Object[] t...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Write a loop equivalent to the for loop above without using .
C Programming Language
Explain the problems that denormalized tables may have for insert, update, and delete actions.
Database Concepts (7th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Suppose that longitude is assigned to the first column of an array and latitude is assigned to the second column of an array. If the user inputs the longitude and the latitude, how do you loop through the 2D array to find which row the longitude and latitude match up? Please use java to answer this question. Here are the variables: double longitude = Double.parseDouble(args[0]); double latitude = Double.parseDouble(args[1]);arrow_forwardimplement this function: chunk(array, size) ? Do not mutate the input array! ? Parameters array - Any JavaScript Array size - A positive integer Number indicating the desired "chunk" size. Return Value A new Array of Arrays. Each sub-Array has a length equal to size. Remaining elements are gathered into a final sub-Array. Do not use Array.prototype.slice in your implementation.Do not use Array.prototype.shift in your implementation.Do not use Array.prototype.pop in your implementation.Do not use Array.prototype.splice in your implementation. Examples chunk(['foo', 'bar', 'baz', 'qux'], 2); // -> [["foo", "bar"], ["baz", "qux"]] chunk([1, 2, 3, 4, 5], 1); // -> [[1], [2], [3], [4], [5]]chunk([false, true, false, true], 3); // -> [[false, true, false], [true]]chunk([], 7); // -> []arrow_forwardWrite a program called Range_array.java that has a method with one integer array and two integers position1 and position2 as parameters, where 0<=position1<=position2<=a.length-1. The method should construct and return an array that is identical to the given array, but with the values in position1 through position2 deleted. The output should look exactly like what is pictured below please. The code must be editable, and all variables defined within please.arrow_forward
- Consider 2 integer arrays, x and y, each with size equal to 10.Initialize array x with random numbers between 1 and 100.Write code that fills array y with values such that each element of y is the corresponding valueof x multiplied by its index.arrow_forwardIn Java Write an application that inputs five numbers, each between 10 and 100, inclusive. As each number is read, display it only if it’s not a duplicate of a number already read. Provide for the “worst case,” in which all five numbers are different. Use the smallest possible array to solve this problem. Display the complete set of unique values input after the user enters each new value. Rough output in screenshotarrow_forwardFor Java , Use for loops to fill in a 2-D array called grid2 that contains the following data (Note this is an array with 7 rows and 9 columns!):// 1 2 3 4 5 6 7 8 9 // 9 8 7 6 5 4 3 2 1// 1 2 3 4 5 6 7 8 9// 9 8 7 6 5 4 3 2 1// 1 2 3 4 5 6 7 8 9// 9 8 7 6 5 4 3 2 1// 1 2 3 4 5 6 7 8 9arrow_forward
- You are given two int variables j and k, an int array zipcodeList that has been declared and initialized, and a boolean variable duplicates. Write some code that assigns true to duplicates if any two elements in the array have the same value, and that assigns false to duplicates otherwise. Use only j, k, zipcodeList, and duplicates. this is a java programarrow_forwardWrite the following java code: Declare an array of int int myArray [] = { 4, 3, 2, 4, 8, 7, 5, 6, 2, 4, 7, 9, 5, 3, 7, 1}; Using an enhanced for loop, print how many elements are greater than 5(count).arrow_forwardYou are given an int variable k, an int array zipcodeList that has been declared and initialized, an int variable nZips that contains the number of elements in zipcodeList, and a bool variable duplicates. Write some code that assigns true to duplicates if there are two adjacent elements in the array that have the same value, and that assigns false to duplicates otherwise. Use only k, zipcodeList, nZips, and duplicates. duplicates = false; for (k=0; !duplicates && k<nZips-1; k++)if (zipcodeList[k] == zipcodeList[k+1]) duplicates = true;arrow_forward
- Do the Random2DArray And the tester is at the bottom import java.util.Random; /** * Store a 2-D array and provide methods to * get the average values of any row, any * column, or the entire array. * * Step 1: Enter your name for @author and today's date for @version * @author * @version */ public class Random2DArray { public final int LOW_LIMIT = -10; public final int HIGH_LIMIT = 10; // Step 2: Declare an instance variable of a 2-D // array of int // Step 3: Complete the constructor /** * Constructs an object of class Random2DArray * by initializing the instance variable to * the passed in parameter. * * @param array a 2-D array of int */ public Random2DArray(int[][] array) { } // Step 4: Complete the constructor /** * Constructs an object of class Random2DArray. * It creates a 2-D array of int with the * specified rows and columns for the instance *…arrow_forwardI am trying to write a code that swaps 1st element of an array with 2nd one, 3rd with 4th and keeps like that. It is not working and instead I wrote a code that is reversing the order. (better explanation on pictures attached.) I am using Java. public static void swapPairs(String[]array) {for(int i= 0; i< array.length / 2; i++) {int j= array.length - i -1;swap(array, i, j);}}public static void swap(String[] array, int i, int j) {String temp= array[i];array[i]= array[j];array[j]= temp;}arrow_forwardGiven an array temps of double, containing temperature data, and an int variable n that contains the number of elements in temps: Compute the average temperature and store it in a variable called avgTemp. Besides temps, n, and avgTemp, you may use only two other variables -- an int variable k and a double variable total, which have been declared.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
9.1: What is an Array? - Processing Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=NptnmWvkbTw;License: Standard Youtube License