(Linear search animation) Write a
FIGURE 22.12 The program animates a linear search. Source: Copyright © 1995–2016 Oracle and/or its affiliates. All rights reserved. Used with permission.
Want to see the full answer?
Check out a sample textbook solutionChapter 22 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Concepts of Programming Languages (11th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Programming Logic and Design (4th Edition)
- do the following: - Create an array of the following temperature readings: 36, 5, 10, 24, 40, 31 - use a loop to find the sum of the elements in the array. -find the average of the numbers. if the average is more than 30 display the message "TOO HOT" on screen otherwise check if the average is between 15 and 30 display the message "MODERATE" otherwise display the message "TOO COLD".arrow_forwardpython: numpy def purchases(transactions): """ QUESTION 7 - A high-end store is trying to evaluate the total amount that customer's spend per transaction. They want customers to spend anywhere between $130 and $150 on average. - You need to determine whether the average number spent on each transaction per month is above, between, or below the desired amount. - Transactions is a numpy array containing a date, total amount earned each month, and total number of transactions each month. - Above: month's average amount spent per transaction > 150 - Within Range: 150 >= month's average amount spent per transaction >= 130 - Below: month's average amount spent per transaction < 130 - Return a numpy array with "Above", "Within Range" and "Below" for the average amount spent per transaction per month - THIS MUST BE DONE IN ONE LINE HINT: use np.where() and convert the type of each column to float Args: transactions…arrow_forwardpart a- 2point) for 3 students find the average of a student by asking him how many grades do you have. The answer to this question, determine the size of the array(list of grades) and then ask the user to enter grades(the number of the grades is equal to the size of the array) then calculate the average for each student. Hence, you will calculate 3 averages. to calculate the average, use the array accumulator. Also when you get each grade validate it. validation for grade means that you check whether a grade is between 0 and 100. if the grade is negative or a grade is more than 100 then it is not valid and you have to ask the user to enter a grade again. Part b- 1 point) Find the maximum and minimum grades for each student. Part c- 1 point) Print the sorted list of the grades for each student. example: if grades user entered are: 60 78 98 23 45 then sorted list is:23 45 60 78 98 (Array not vector)arrow_forward
- You can copy all elements of one array into one another with an assignment statement. True or Falsearrow_forwardAny loop statement can be used to traverse an array. True or Falsearrow_forward1) Given row array vals of unknown size of 2 or greater, write an expression that yields a new array containing all elements except the first. For example, if vals = [10, 20, 30, 40], the expression would yield [20, 30, 40]. vals Check Show answer 2) Write an expression that results in a row array vals shifted to the right. For example, if vals = [1, 2, 3, ....., n-1, n], then a right shift will result in [n,1,2,3,.....n-1]. Check Show answer Incorrect vals(???)arrow_forward
- Question 1 Write a program that declares an array of 100 doubles. The program asks the user to enter a number N between 100, and then: initializes the first N elements of the array to random numbers between 1 and 100. calculates the average of these numbers and displays it. A final loop displays the elements of the array, each on a line, with an indication as to whether that number is lower or higher than the average. For example, if the numbers generated are 5, 28, 3, 8, 15, 7, 22, 6, 1, 4, then the program will print: Average = 9.9 5 28 3 8 15 7 22 6 1 4 11 11 11 -- 11 11 1- —— 11 lower than average higher than average lower than average lower than average higher than average lower than average higher than average lower than average lower than average lower than averagearrow_forward5. Create an array that contents 10 integer elements, and let user randomly input 10 values and put into the array, Sorts array elements in ascending order, and then print out the array element.arrow_forwardLottery Number Generator Problem Use pseudocode to design a program that generates a 7-digit lottery number. This program should have an integer array with 7 elements. Then Write a loop that steps through the array, randomly generating a number in the range of 0 through 9 for each element. Finally, write another loop that displays the contents of the array.arrow_forward
- Problem2 Write a program that display the position of a given element in an array. You should print the index (i.e. the position) of the element. If the element appears more than one time than you should print all its positions. The size of the array should be entered by the user. If the element does not occur then you should display element not found. Sample1: Enter the size of the array: 5 Enter an array of size 5: 44 5 13 44 67 Enter the element to find: 44 44 is found at position 44 is found at position 44 occurs 2 time(s) Sample2: Enter the size of the array: 4 Enter an array of size 4: 12 150 17 20 Enter the element: 18 18 is not foundarrow_forward2. Creates an array of Triangle type of size 10. Prompts the user to enter the index of the array, then displays the area of corresponding element value. If the specified index is out of bounds, display the message Out of Bounds.arrow_forwardProblem Description - JAVA PROGRAMMING Use a Two-dimensional (3x3) array to solve the following problem: Write an application that inputs nine numbers, each of which is between 1 and 10, inclusive. Display the array after the user inputs each value. Rotate/flip the array by changing places. Make the rows columns and vice versa. You have to move the elements to their new locations. Remember to validate the input and display an error message if the user inputs invalid data. Documentation and the screenshot(s) of the results. Example: 1 2 3 4 5 6 7 8 9 the result will be : 1 4 7 2 5 8 3 6 9arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage