Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 17, Problem 2PC
Sorting Objects with the Quicksort
The IntQuickSorter class presented in this chapter sorts an array of int values. Create an ObjectQuickSorter class that can sort Comparable objects. Demonstrate the class in a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Java programming
please write clear or send clear pictures
Return an ArrayList containing the largest and smallest integer inan array. If the array is empty, return the largest andsmallest as 0.
languages java
please help me
thanks
Using jGRASP please de-bug this
/**This program demonstrates an array of String objects.It should print out the days and the number of hours spent at work each day.It should print out the day of the week with the most hours workedIt should print out the average number of hours worked each dayThis is what should display when the program runs as it shouldSunday has 12 hours worked.Monday has 9 hours worked.Tuesday has 8 hours worked.Wednesday has 13 hours worked.Thursday has 6 hours worked.Friday has 4 hours worked.Saturday has 0 hours worked.Highest Day is Wednesday with 13 hours workedAverage hours worked in the week is 7.43 hours*/{public class WorkDays{public static void main(String[] args){String[] days = { "Sunday", "Monday", "Tuesday","Wednesday", "Thursday", "Friday", "Saturday"};
int[] hours = { 12, 9, 8, 13, 6, 4};
int average = 0.0;int highest = 0;String highestDay = " ";int sum = 0;
for (int index = 0; index < days.length; index++){System.out.println(days[index] + " has "…
Chapter 17 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Ch. 17.1 - Prob. 17.1CPCh. 17.1 - Prob. 17.2CPCh. 17.1 - Prob. 17.3CPCh. 17.1 - Prob. 17.4CPCh. 17.2 - Prob. 17.5CPCh. 17.2 - Prob. 17.6CPCh. 17.2 - Prob. 17.7CPCh. 17.2 - If a sequential search is performed on an array,...Ch. 17.3 - Prob. 17.9CPCh. 17.3 - Prob. 17.10CP
Ch. 17.3 - Prob. 17.11CPCh. 17.3 - Prob. 17.12CPCh. 17.3 - Prob. 17.13CPCh. 17.3 - Prob. 17.14CPCh. 17.3 - Let a[ ] and b[ ] be two integer arrays of size n....Ch. 17.3 - Prob. 17.16CPCh. 17.3 - Prob. 17.17CPCh. 17.3 - Prob. 17.18CPCh. 17 - Prob. 1MCCh. 17 - Prob. 2MCCh. 17 - Prob. 3MCCh. 17 - Prob. 4MCCh. 17 - Prob. 5MCCh. 17 - Prob. 6MCCh. 17 - Prob. 7MCCh. 17 - Prob. 8MCCh. 17 - Prob. 9MCCh. 17 - Prob. 10MCCh. 17 - True or False: If data is sorted in ascending...Ch. 17 - True or False: If data is sorted in descending...Ch. 17 - Prob. 13TFCh. 17 - Prob. 14TFCh. 17 - Assume this code is using the IntBinarySearcher...Ch. 17 - Prob. 1AWCh. 17 - Prob. 1SACh. 17 - Prob. 2SACh. 17 - Prob. 3SACh. 17 - Prob. 4SACh. 17 - Prob. 5SACh. 17 - Prob. 6SACh. 17 - Prob. 7SACh. 17 - Prob. 8SACh. 17 - Prob. 1PCCh. 17 - Sorting Objects with the Quicksort Algorithm The...Ch. 17 - Prob. 3PCCh. 17 - Charge Account Validation Create a class with a...Ch. 17 - Charge Account Validation Modification Modify the...Ch. 17 - Search Benchmarks Write an application that has an...Ch. 17 - Prob. 8PCCh. 17 - Efficient Computation of Fibonacci Numbers Modify...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What does a comparator do?
Digital Fundamentals (11th Edition)
Write code that opens an output file with the filename number_list. txt, but does not erase the file's contents...
Starting Out with Python (4th Edition)
What output will be produced by the following code?
Java: An Introduction to Problem Solving and Programming (8th Edition)
Which of the following loops would you use to read all of the items from the file associated with myFile? a. Wh...
Starting Out with Programming Logic and Design (4th Edition)
Describe the difference between the seekg and the seekp functions.
Starting Out with C++: Early Objects (9th Edition)
Define a class for complex numbers. A complex number is a number of the form a + b i where, for our purposes, ...
Problem Solving with C++ (9th 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
- Searching and sorting in Java programming: Write a method remove, that takes three parameters: an array of integers, the length of the array, and an integer, say removeItem. The method should find and delete the first occurrence of removeItem in the array. If the value does not exist or the array is empty, output an appropriate message. Note: after deleting the element, the array size is reduced by 1. You may assume that the array is unsorted. Thank you. I took Java in 2012 and 2013, and we didn't go too deep in this cocept..just a little bit in the Arrays chapter. i wanted to try something ne! Thank you!arrow_forwardRooks on a rampage def safe_squares_rooks(n, rooks): A generalized n-by-n chessboard has been invaded by a parliament of rooks, each rook represented as a two-tuple (row, column) of the row and the column of the square that the rook is in. Since we are again computer programmers instead of chess players and other normal folks, our rows and columns are numbered from 0 to n - 1. A chess rook covers all squares that are in the same row or in the same column. Given the board size n and the list of rooks on that board, count the number of empty squares that are safe, that is, are not covered by any rook. To achieve this in reasonable time and memory, you should count separately how many rows and columns on the board are safe from any rook. Because permuting the rows and columns does not change the answer to this question, you can imagine all these safe rows and columns to have been permuted to form an empty rectangle at the top left corner of the board. The area of that safe rectangle is…arrow_forwardRecipe Program - Java ONLYI am looking to create a program that is a recipe holder. It needs to include at a minimum: At least 1 loop An Array or ArrayList At least 3 Java classes Use of methods The program would allow the user to (as part of a menu selection): Add a recipe Include ingredient list Instructions List all recipes that are in the program (array) Display a single recipe Search Recipes (option to view recipe selected) For example, searching for peanut butter cookie would bring up the recipe or multiple if the same name. The user could then select one of them to view the recipe. Search Recipes with a single ingredient (option to view recipe selected) For example: search for coconut and it would bring up coconut cream pie and German chocolate cake. The user could then select one of them to view the recipe. Close application Also need the program in a UML diagram.arrow_forward
- Enhanced selection sort algorithm SelectionSortDemo.java package chapter7; /** This program demonstrates the selectionSort method in the ArrayTools class. */ public class SelectionSortDemo { public static void main(String[] arg) { int[] values = {5, 7, 2, 8, 9, 1}; // Display the unsorted array. System.out.println("The unsorted values are:"); for (int i = 0; i < values.length; i++) System.out.print(values[i] + " "); System.out.println(); // Sort the array. selectionSort(values); // Display the sorted array. System.out.println("The sorted values are:"); for (int i = 0; i < values.length; i++) System.out.print(values[i] + " "); System.out.println(); } /** The selectionSort method performs a selection sort on an int array. The array is sorted in ascending order. @param array The array to sort. */ public static void selectionSort(int[] array) { int startScan, index, minIndex, minValue; for (startScan = 0; startScan < (array.length-1); startScan++) { minIndex = startScan; minValue…arrow_forwardEnhanced selection sort SelectionSortDemo.java package chapter7; /** This program demonstrates the selectionSort method in the ArrayTools class. */ public class SelectionSortDemo { public static void main(String[] arg) { int[] values = {5, 7, 2, 8, 9, 1}; // Display the unsorted array. System.out.println("The unsorted values are:"); for (int i = 0; i < values.length; i++) System.out.print(values[i] + " "); System.out.println(); // Sort the array. selectionSort(values); // Display the sorted array. System.out.println("The sorted values are:"); for (int i = 0; i < values.length; i++) System.out.print(values[i] + " "); System.out.println(); } /** The selectionSort method performs a selection sort on an int array. The array is sorted in ascending order. @param array The array to sort. */ public static void selectionSort(int[] array) { int startScan, index, minIndex, minValue; for (startScan = 0; startScan < (array.length-1); startScan++) { minIndex = startScan; minValue =…arrow_forwardNumber each step please! Create a program that 1. Initializes a game object. 2. Reads a file of signs and stores each sign in an ArrayList<String> in the game object. 3. Reads a file of outcomes, storing each outcome twice in a two-dimensional array in the game object (diagonals should be empty). 4. Prints out the list of signs and the two-dimensional array of outcomes to the screen.arrow_forward
- Jordan University of Science and TechnologyCS415 Contemporary Programming TechniquesMidterm Exam – Second semester 2021Name: ID: Section:Important note: your code must compile correctly and run without errors.Otherwise your code will get the grade zero.Question 1: Implement a java class called ParsingCustomerRecords that has thefollowing data members and functions:ParsingCustomerRecods- customerRecords: array of strings- result: string variable- recordsNumber: int variable-fileName: string variable+ Constructor(String filename, int recordsNumber)+ void Reader()+ void Executor()+ void showResult()+ String toString()All of the data members are private, and all of the methods are public.Constructor has two parameters which are (1) the file name in which Customers’ recordsare stored, and (2) the number of the records in the file. The constructor functionality is toassign suitable initial values to the fileName and recordsNumber data members. Theconstructor also should instantiate the…arrow_forwardMovie. Java Codearrow_forwardComputer Science Java Program Write a program in Java that takes in a user-submitted file that is a grid of 0s and 1s. Represent the grid as a two-dimensional array. Write a program that: a. computes the size of a group when a square in the group is given b. computes the numbers of different groups c. lists all groups Example: userInput.txt: 0 0 0 0 0 0 0 0 0 10 0 0 1 1 0 0 0 0 10 0 0 0 0 0 0 0 0 00 0 0 0 1 0 0 1 0 00 0 0 1 0 0 0 1 0 00 0 0 0 0 0 0 1 1 00 0 0 0 1 1 0 0 0 00 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 The program should output three things: The size of the group in which location specified by the user belongs. then if the user enters 1,2 the answer is 0 1,4 the answer is 2 3,4 the answer is 1 4,7 the answer is 4 The number of each size group Size Count 2 3 1 List of each group’s locations 1: (0,9) (1,9) 2: (1,3) (1,4) 3: (3,4) 4: (3,7) (4,7) (5,7) (5,8) 5: (4,3) 6: (6,4) (6,5)arrow_forward
- Java programmingarrow_forward1. Given a string of at least 3 characters as input, if the length of the string is odd return the character in the middle as a string. If the string is even return the two characters at the midpoint. public class Class1 { public static String midString(String str) { //Enter code here } } ----------- 2. Given an array of integers return the sum of the values stored in the first and last index of the array. The array will have at least 2 elements in it public class Class1 { public static int endSum(int[] values) { //Enter code here } } ----------- 3. The method takes a string as a parameter. The method prints treat if the string is candy or chocolate (of any case, such as CaNdY) Otherwise print trick import java.util.Scanner; public class Class1 { public static void trickOrTreat(String str) { //Enter code here } public static void main(String[] args) { Scanner s = new Scanner(System.in); trickOrTreat(s.nextLine()); } }arrow_forwardDNA Max Write code to find which of the strands representing DNA in an array String[] strands representing strands of DNA has the most occurrences of the nucleotide represented by parameter nuc. Complete the definition of the class DnaMax and method definition maxStrand shown below. If more than one strand has the same maximal number of the specified nucleotide you should return the longest strand with the maximal number. All DNA strands have different lengths in this problem so the maximal strand will be unique when length is accounted for. Return this uniquely maximal strand. Each String representing a DNA strand will contain only cytosine, guanine, thymine, and adenine, represented by the characters 'c', 'g', 't', and 'a', respectively. If no strand in the array contains the specified nucleotide return the empty string "". public class DnaMax { public String maxStrand(String[] strands, String nuc) { // fill in code here } } Constraints strands will contain no more than 50 elements,…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
9.1: What is an Array? - Processing Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=NptnmWvkbTw;License: Standard Youtube License