(Binary search animation) Write a
FIGURE 22.13 The program animates a binary 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
Computer Science: An Overview (12th Edition)
Software Engineering (10th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
C Programming Language
Digital Fundamentals (11th Edition)
Starting Out With Visual Basic (7th Edition)
- Use Math Lab code Programming (Code needed)arrow_forward2. Lottery Number Generator Design a program that generates a 7-digit lottery number. The program should have an Integer array with 7 elements. Write a loop that steps through the array, ran- domly generating a number in the range of 0 through 9 for each element. (Use the random function that was discussed in Chapter 6.) Then write another loop that displays the contents of the array.arrow_forward(1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers in one int array and the ratings in another int array. Output these arrays (i.e., output the roster). (2) Implement a menu of options for a user to modify the roster. Each option is represented by a single character. The program initially outputs the menu, and outputs the menu after a user chooses an option. The program ends when the user chooses the option to Quit. For this step, the other options do nothing (3) Implement the "Output roster" menu option. (4) Implement the "Update player rating" menu option. Prompt the user for a player's jersey number. Prompt again for a new rating for the player, and then change that player's rating. (5) Implement the "Output players above a rating" menu option. Prompt the user for a rating. Print the jersey number and rating for all players with ratings above the entered value. (6) Implement the "Replace…arrow_forward
- python: 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_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_forwarddo 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_forward
- 1) 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_forwardYou can copy all elements of one array into one another with an assignment statement. True or Falsearrow_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
- Instructions: Using an array, enhance the program that you have performed in the previous exercise. The program should accept multiple entries and iteratively perform the following operations. Submit the source code and screenshot of output. Using a user-defined function and appropriate conditional and looping statements, create a program that will: (a) ask the item price from the user (b) ask how many items to purchase for a specific item price (c) ask if there are other items to purchase, if yes, repeat the first step, proceed to the next step if otherwise (d) compute and display for the total amount to pay (e) ask for the payment from the user (f) accepts only enough amount of payment, ask another payment if otherwise (3) compute and display changearrow_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_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
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage