Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter 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
int [] arrayInt={3,54,90,22,32};
To print the last element in the arrayInt you will write:
a.
System.out.println(arrayInt[5]);
b.
System.out.println(arrayInt[0]);
c.
System.out.println(arrayInt[length]);
d.
System.out.println(arrayInt[4]);
В.width; }
{ t = B.type; w =
{ T.type = C.type; T.width = C.width; }
T → B
C
В > int
{ B.type = integer; B.width
4; }
В — foat
{ B.type = float; B.width =
8; }
{ C.type = t; C.width
= w; }
C - [ num] C1 = array(num. value, C1.type);
{ C.type
C.width
= num. value x C1. width; }
int A[3] [4]={{ 4, 6, 7, 9},{ 1, 3, 4, 3},{-5, 6, 7, 2}};
int sum, row, col;
sum
= 0;
for (col=0;col<=3;i++)
sum+=A[0] [col];
what is the value of sum calculated
the number of elements on row 0
the total addition of elements on row 0
the total addition of first 3 elements on row 0
the total addition of all the elements
Chapter 7 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
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.6 - Prob. 34STQCh. 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 - A palindrome is a word or phrase that reads the...Ch. 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
Determine the maximum deflection of the simply supported beam. The beam is made of wood having a modulus of ela...
Mechanics of Materials (10th Edition)
Determine the normal force that the 100-lb plate A exerts on the 30-lb plate B. Prob. F6-17
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
What is the value of the program counter in the Vole immediately after executing the instruction 0xB0CD?
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
_____ is the only language computers can process directly, without any conversion required.
Starting Out With Visual Basic (8th 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
- #include <iostream> using namespace std; const int ROWS = 10; const int COLS = 10; int generateRND(int MIN, int MAX) { return rand() % (MAX - MIN + 1) + MIN; } void initializeArray(int C[][COLS], int min, int max) { for (size_t i = 0; i < ROWS; i++) { for (size_t j = 0; j < COLS; j++) { C[i][j] = generateRND(min, max); } } } void swap(int A[][COLS], int B[][COLS]) { int temp; for (size_t j = 0; j < COLS; j += 2) { for (size_t j = 0 ; j< COLS; j +=) } } void printArray(int C[][COLS]) { for (size_t i = 0; i < ROWS; i++) { for (size_t j = 0; j < COLS; j++) { cout << C[i][j] << " "; } cout << endl; } } int main() { srand((unsigned)time(0)); int A[ROWS][COLS] = { 0 }; int B[ROWS][COLS] = { 0 }; const int MIN = 2; const int MAX = 50; initializeArray(A, 2, 50); } Declares two 10X10 Two-dimensional arrays A and B of type integer. Each array consists of 100 random integers between 2 and 50. 1. Swaps (exchange) the elements of A with…arrow_forward#include <iostream> using namespace std; const int ROWS = 10; const int COLS = 10; int generateRND(int MIN, int MAX) { return rand() % (MAX - MIN + 1) + MIN; } void initializeArray(int C[][COLS], int min, int max) { for (size_t i = 0; i < ROWS; i++) { for (size_t j = 0; j < COLS; j++) { C[i][j] = generateRND(min, max); } } } void swap(int A[][COLS], int B[][COLS]) { int temp; for (size_t j = 0; j < COLS; j += 2) { for (size_t j = 0 ; j< COLS; j +=) } } void printArray(int C[][COLS]) { for (size_t i = 0; i < ROWS; i++) { for (size_t j = 0; j < COLS; j++) { cout << C[i][j] << " "; } cout << endl; } } int main() { srand((unsigned)time(0)); int A[ROWS][COLS] = { 0 }; int B[ROWS][COLS] = { 0 }; const int MIN = 2; const int MAX = 50; initializeArray(A, 2, 50); } Declares two 10X10 Two-dimensional arrays A and B of type integer. Each array consists of 100 random integers between 2 and 50. Swaps (exchange) the elements of odd rows of A…arrow_forwarddef clipping_2d_array(array, threshold):"""Iterate through each element of the 2d array using nested loops.Set the values greater than a threshold value equal to the threshold value given as an input parameter.(E.g. if the threshold is 1 and there is a value 1.5, set the value to 1 in the array):param array: a 2d array:param threshold: a threshold value (valid int or float)"""passarrow_forward
- 8arrow_forwardBelow is code which defines and creates an Array, myList: int [] myList = new int [5]; //define and create The loop below stores the values 1 to 5 in myList: for (int i = 0; i< 5; i++) { myList [i] =i+1; //store values using a loop The loop below prints the values from first to last in myList: for (int i = 0; i< myList.length; i++) { System.out.print(myList [i]+""); The code below is used to get user from the user and calculate the sum: import java.util."; public class WhileWithInput { public static void main(String[] args) { Scanner reader = new Scanner (System.in); int count = 1; double total = 0; while (count <= 5) { System.out.println("Enter a decimal number"); double number = reader.nextDouble(); total = total + number; count = count + 1; System.out.printlin("The total is "+ total); } System.out.println("The total is "+ total); } 1 CPS 2231 Chapter 7- lab 2 Fall 2019 Use the examples on page 1 to complete the lab below. Please submit a screen print of the Eclipse editor showing…arrow_forward//Required Functionvoid func(int array_1[],int array_2[],int size){ for(int i=0;i<size;i++){ if(array_2[i]>array_1[i]){ array_1[i]=array_2[i]; } } return;} //main function to test the function.int main(){ int size=6; int a[]={1,5,9,8,7,6}; int b[]={1,4,10,12,7,15}; printf("First array before function call: "); for(int i=0;i<size;i++){ printf("%d ",a[i]); } func(a,b,size); //call to the created function printf("\nFirst array after function call: "); for(int i=0;i<size;i++){ printf("%d ",a[i]); } return 0;} 1. Write the statements to do the following: write a prototype for your function in the previous problem write a main function which includes the following steps declare two arrays of ints with 25 elements each prompt the user and read values into both arrays call your function from the previous problem print both arraysarrow_forward
- int[] array = { 1, 4, 3, 6 }; What would be a proper syntax to access 3 from this array?arrow_forwardPlease add proper comments in the code given below. int maxSubArray(vector<int>& nums) { int csum=0,maxsum=INT_MIN; for(int i=0;i<nums.size();i++) { csum+=nums[i]; if(csum>maxsum)maxsum=csum; if(csum<0)csum=0; } return maxsum; }arrow_forwardAn array of 20 floats intended to store marks as a percentage. #include <iostream> #include <stdio.h> const float marks = 20; int main() { float array[marks]; int i; for(i=0; i < marks;i++); { printf("enter marks %d",i); scanf("%d%*c",&array[i]); } printf("marks are :\n"); for(i=0; i< marks;i++); { printf("marks %d is %d\n",i,array[i]); } return 0; }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