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
Question
Chapter 11, Problem 7PP
Program Plan Intro
Combinations of array
Program plan:
- Import required packages
- Define the class “Subarray”.
- Define the class “main”
- Declare and initialize the array.
- Declare the array.
- Call the method.
- Define the method “findProduct()”.
- Check whether the value is greater than the array length
- Return the values.
- Iterate till “i” is less than the array length
- Assign he index value of “i” to the array
- Call the method “findProduct()”.
- Check whether the “value” equals to the array length
- Call the method “displayItems()”.
- Iterate till “i” is less than the array length
- Return the values.
- Check whether the value is greater than the array length
- Define the method “displayItems()”.
- Iterate till “i” is less than the array length
- Print the value
- Print new line.
- Iterate till “i” is less than the array length
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that prints an mxn matrix whose dimensions are specified by the user. Let the matrix values be random variables. You must use it within the repetition cycle.
Example format:
Enter dimension of matrix mxn: 2 4
The 2x4 matrix is :
1 2 3 4
5 6 7 8
Using recursion, write a Python function
def countOdds(A)
which which takes an array of integers A as input and returns the number of elements in the array that are odd.
For example, if A is [1,2,5,3,6,5,3,5,5,4] the the function should return 7. If A is empty then it should return 3.
Hint: To check if n is odd it suffices to check if dividing it by 2 gives remainder 1 (in Python, this remainder is calculated by n%2).
Write a program for the following information: Year has 365 days. You create array for temperature of each day in a year. Assign random temp values range of 30-110. Using a function Search in the array do you have 100 degree and what days. Print how many days and what days. Also print the Temp array in nice format in a function. Sample output
Chapter 11 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 11.1 - What output will be produced by the following...Ch. 11.1 - What is the output produced by the following code?Ch. 11.1 - Write a recursive definition for the following...Ch. 11.1 - What is the output of the following code? public...Ch. 11.1 - Prob. 5STQCh. 11.1 - Complete the definition of the following method....Ch. 11.2 - Revise the method getCount in Listing 11.5 so that...Ch. 11.2 - Prob. 8STQCh. 11.2 - Prob. 9STQCh. 11.2 - Suppose you want me class ArraySearcher to work...
Ch. 11.2 - What Java statement will sort the following array,...Ch. 11.2 - How would you change the class MergeSort so that...Ch. 11.2 - How would you change the class MergeSort so that...Ch. 11.2 - If a value in an array of base type int occurs...Ch. 11.3 - Convert the following event handler to use the...Ch. 11 - What output will be produced by the following...Ch. 11 - What output will be produced by the following...Ch. 11 - Write a recursive method that will compute the...Ch. 11 - Write a recursive method that will compute the sum...Ch. 11 - Complete a recursive definition of the following...Ch. 11 - Write a recursive method that will compute the sum...Ch. 11 - Write a recursive method that will find and return...Ch. 11 - Prob. 8ECh. 11 - Write a recursive method that will compute...Ch. 11 - Suppose we want to compute the amount of money in...Ch. 11 - Prob. 11ECh. 11 - Write a recursive method that will count the...Ch. 11 - Write a recursive method that will remove all the...Ch. 11 - Write a recursive method that will duplicate each...Ch. 11 - Write a recursive method that will reverse the...Ch. 11 - Write a static recursive method that returns the...Ch. 11 - Write a static recursive method that returns the...Ch. 11 - One of the most common examples of recursion is an...Ch. 11 - A common example of a recursive formula is one to...Ch. 11 - A palindrome is a string that reads the same...Ch. 11 - A geometric progression is defined as the product...Ch. 11 - The Fibonacci sequence occurs frequently in nature...Ch. 11 - Prob. 4PPCh. 11 - Once upon a time in a kingdom far away, the king...Ch. 11 - There are n people in a room, where n is an...Ch. 11 - Prob. 7PPCh. 11 - Prob. 10PPCh. 11 - Prob. 12PP
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
- please do this in C++ code. our topic is in 2d arrayarrow_forwardWrite a recursive function that takes as a parameter a nonnegative integer and generates the following pattern of stars. If the nonnegative integer is 4, the pattern generated is as follows: **** *** ** * * ** *** **** Also, write a program that prompts the user to enter the number of lines in the pattern and uses the recursive function to generate the pattern. For example, specifying 4 as the number of lines generates the preceding pattern.arrow_forwardUsing a Java program solve the following problem using arrays: Past A: Coupon collector is a classic statistic problem with many practical applications. The problem is to pick objects from a set of objects repeatedly and determine how many picks are needed for all the objects to be picked at least once. A variation of the problem is to pick cards from a shuffled deck of 52 cards repeatedly and find out how many picks are needed before you see one of each suit. Assume a picked card is placed back in the deck before picking another. Write a program to simulate the number of picks needed to get total of four cards from each different suit and display the four cards picked (it is possible that a card may be picked twice). Here is a sample run of the program: Queen of Spades 5 of Clubs Queen of Hearts 4 of Diamonds Number of picks: 12 Sample run explanation: As you see in the above run, 12 picks are made to get the four cards from different suits. The other 8 picks (12-4-8) were from the…arrow_forward
- Write a program that reads two integer matrices and performs multiplication. Also, print the output matrix. The size of the matrices are to be taken from the user.arrow_forwardYou are a movie theater manager. You are given a two-dimensional array with 6 rows and 6 columns - 36 elements with O value, that represent empty theater seats. All 36 tickets for session were sold, so you need to identify all of the seats with value 1. Write a program that replaces all O values in the given array, by 1 and outputs the resulting matrix. Use nested for-loops to iterate over two-dimensional matrix.arrow_forwardSolve It In C Language By Using Array 6. The electric company charges according to the following rate schedule: 9 cents per kilowatt-hour (kwh) for the first 300 kwh 8 cents per kwh for the next 300 kwh (up to 600 kwh) 6 cents per kwh for the next 400 kwh (up to 1,000 kwh) 5 cents per kwh for all electricity used over 1,000 kwh Write a function to compute the total charge for each customer. Write a main function to call the charge calculation function using the following data: Customer Number Kilowatt-hours Used 123 725 205 115 464 600 596 327 … … The program should print a three column chart listing the customer number, the kilowatt hours used, and the charge for each customer. The program should also compute and print the number of customers, the total kilowatt hours used, and the total charges.arrow_forward
- /arrow_forwardWrite a function that takes a one-dimensional array and its size [10], and then fill each location in the array by the cubic of the location's index. To cube the location's index write your function int cube(int x). Then print out your array. Consider the following three functions in your program: int cube(int x). • void fillArray(int [], int size). • void printArray(int [], int size). Sample input / output: The generated array is: 0 1 8 27 64 125 216 343 512 729arrow_forwardCreate a array of size n and poulate it with random numbers in range @ to 150. Print the maximum number in the array. Take n as input by user. Write whole code in main function only.Given n>=1 and narrow_forward
- A scientist has developed a mathematical model for a physical process, and he wants to check how good is model is. To evaluate the correctness of his model, he wants to test the results of his model under certain parameters and compare them with experimental results. Write a program that first reads the number of tests (testCount) as an int followed by the results of each test according to the model as a double array (test Model) and finally the results of each test according to experiments as a double array (testExperiment). Then, the program should calculate the error of the model by evaluating the average of the squares of the differences between the model result and experimental result (see formula below) using a function. Error Input 1 testCount NOTE: Individual square of the difference between the model value and the experiment value calculations MUST be done in the function. Every other functionality MUST be done in the main function. NOTE: To calculate square of a number you…arrow_forward3. Write a program to find intersection of two sorted array.For example, if the two sorted arrays as input are {21, 34, 41, 22, 35} and {61, 34, 45, 21, 11}, it should returnan intersection array with numbers {34, 21}. For the sake of this Problem, you can assume that numbers ineach integer array are unique.arrow_forwardSuppose you are given a 6 * 6 matrix filled with 0 and 1. All rows and all columns have the even number of 1s. Let the user flip one cell (i.e., flip from 1 to 0 or from 0 to 1) and write a program to find which cell was flipped. Your program should prompt the user to enter a 6 * 6 array with 0 and 1 and find the first row r and first column c where the parity is violated (i.e., the number of 1’s is not even). The flipped cell is at (r, c).arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning