Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 7.3, Problem 17STQ
Suppose a is an array of values of type double. Write some code to display all the elements in a on the screen, one element per line.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
1. Create an array named arr1 with 20 random numbers between 1 and 10(inclusively). Then
produce a new array arr2 based on arr1 as follows: arr2 has the same length as arr1. In arr2, each
element is the sum of the corresponding element in arr1 and the previous element of arr1, except
the first number in arr2 equals the first number in arr1. For example,
If arr1 has the elements:
Then arr2 will be:
2 5 19 3 7 6...
2 7 6 10 12 10 13...
Please display the two arrays.
Write a program that creates a 2D array of size 4x5. Then, user enters the elements for this 2D array. Display the array in tabular form, using manipulators.
Write a loop that sets each array element to the sum of itself and the next element, except for the last element which stays the same. Be careful not to index beyond the last element. Ex:Initial scores: 10, 20, 30, 40 Scores after the loop: 30, 50, 70, 40 The first element is 30 or 10 + 20, the second element is 50 or 20 + 30, and the third element is 70 or 30 + 40. The last element remains the same.
#include <iostream>using namespace std;
int main() { const int SCORES_SIZE = 4; int bonusScores[SCORES_SIZE]; int i;
for (i = 0; i < SCORES_SIZE; ++i) { cin >> bonusScores[i]; }
/* Your solution goes here */
for (i = 0; i < SCORES_SIZE; ++i) { cout << bonusScores[i] << " "; } cout << endl;
return 0;}
Chapter 7 Solutions
Java: An Introduction to Problem Solving and Programming (7th 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 - 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
Create an ArrayList<String> in the Code Pad by typing the following two lines:
If you write the last line wi...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Suppose you change Self-Test Exercise 15 so that the definition of the class Automobile omits the line that con...
Problem Solving with C++ (9th Edition)
What is the disadvantage of having too many features in a language?
Concepts of Programming Languages (11th Edition)
Fill in the blanks in each of the following: Keyword in a class declaration is followed immediately by the clas...
Java How To Program (Early Objects)
Rock, Paper, Scissors Game Write a program that lets the user play the game of Rock, Paper, Scissors against th...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Use the following tables for your answers to questions 3.7 through 3.51 : PET_OWNER (OwnerID, OwnerLasst Name, ...
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
- Write a loop that sets each array element to the sum of itself and the next element, except for the last element which stays the same. Be careful not to index beyond the last element. Ex: Initial scores: 10, 20, 30, 40 Scores after the loop: 30, 50, 70, 40 The first element is 30 or 10 + 20, the second element is 50 or 20 + 30, and the third element is 70 or 30 + 40. The last element remains the same. 324758.2040686.qx3zqy7 1 #include 2 3 int main(void) { const int SCORES SIZE = 4; int bonusScores[SCORES_SIZE]; int i; 4 6. for (i = 0; i < SCORES_SIZE; ++i) { scanf("%d", &(bonusscores[i])); } 8 9. 10 11 12 * Your solution goes here */ 13 for (i = 0; i < SCORES_SIZE; ++i) { printf("%d ", bonusscores[i]); 14 15 16 17 printf("\n"); 18arrow_forwardWrite a loop that sets each array element to the sum of itself and the next element, except for the last element which stays the same. Be careful not to index beyond the last element. Ex:Initial scores: 10, 20, 30, 40 Scores after the loop: 30, 50, 70, 40 The first element is 30 or 10 + 20, the second element is 50 or 20 + 30, and the third element is 70 or 30 + 40. The last element remains the same. #include <iostream>using namespace std; int main() {const int SCORES_SIZE = 4;int bonusScores[SCORES_SIZE];int i; for (i = 0; i < SCORES_SIZE; ++i) {cin >> bonusScores[i];} /* Your solution goes here */ for (i = 0; i < SCORES_SIZE; ++i) {cout << bonusScores[i] << " ";}cout << endl; return 0;} Please help me with this issue using c++.arrow_forwardCreate a 4x3 array of letters from a through l and call it array1. Copy the array and call it array2, then reshape array2 to a 6x2 array. Create another copy of the array, called array3, and flatten it into a one-dimensional array. Print all three arrays.arrow_forward
- JAVAWrite a program that searches person's name and display all matched name. For example, if a user inputs the letter "Davis", the program searches all name which includes "Davis" in an array. Then, display all matched names on the screen. You must declare a single dimensional array which has all people’s name. Use methods of string classarrow_forwardConsider an array x contains 8 integer numbers. Write a Visual Basic code to sort the array x in a descending order.arrow_forwardWrite the code of dynamic array with the name of ‘A’ and you will get the size of array from user and also get the values of array from the user and display that values on screen. TRY TO ADD COMMENTS IN THE CODE TOOarrow_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_forward2. Write a program that will load A with 15 random numbers (range : 1-50). Display elements of A in ascending order. Then get a number X. Compare X to each element of A, if array element is less than X, replace that element with X. On another line, display elements of A after replacing all elements less than X with X.arrow_forward//1. Declare an array arr1 and initialize it to 1, 2, 3, 4, 5, 6, 7, 8, and 9//2. Declare another array arr2, the same length as arr1, without// giving it any initial values.//3. Using a for loop print arr1 displaying all elements on one line,// separated by a comma. (Commas must be placed only between numbers.)//4. Using a while loop print arr2 displaying all elements on one// line, separated by a dash. (Dashes must be placed only between numbers.)//5. Using a for loop, copy all the values of arr1 into arr2 in reverse// order. DO NOT print on this step.//6. Using a do/while loop, print arr1 displaying all elements on// one line, separated by a comma.//7. Using a for loop, print arr2 displaying all elements on one line,// separated by a dash.arrow_forward
- 4. Create a main method that will create a 2-d array with 4 rows and 5 columns. Call the method from number 3 to fill the array with values. Use a loop to find the max of each row and then curve each row so that the max is turns into 100.arrow_forwardCreate an array of size 4 of Cat data type, add all 4 Cats into your array. I Print information about all 4 Cats formatted in a table form using for-each looparrow_forwardExercise: create an array (26) and then use for loop to: 1. assign to its elements the English letters from A to Z. 2. print the letters on a Message boxes.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