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 12.3, Problem 25STQ
Redefine the method getDataAtCurrent in StringLinkedListWith Iterator (Listing 12.9) so that it throws an exception instead of ending the
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write the method stringSplosion().* * The method takes one parameter, non-empty String str (such as "Code") and* returns a String in the form "CCoCodCode". Notice that this includes the* first character of the original String, followed by the first two characters,* and so on until the whole String is used.* * Examples: stringSplosion("Code") returns "CCoCodCode" stringSplosion("abc")* returns "aababc" stringSplosion("x") returns "x"* * @param str the input String to process.*, @return a new String as described above.
Use for loops
This is Java project plz solve it thanks!
In this problem you will fill out three functions to complete the Group ADT and the Diner ADT. The goal is to organize how
diners manage the groups that want to eat there and the tables where these groups sit.
It is important to take the time to read through the docstrings and the doctests. Additionally, make sure to not violate
abstraction barriers for other ADTS, i.e. when implementing functions for the Diner ADT, do not violate abstraction barriers for
the Group ADT, and vice versa.
# Diner ADT
def make_diner (name):
""" Diners are represented by their name and the number of free tables they have."""
return [name, 0]
def num_free_tables (diner):
return diner [1]
def name (diner):
return diner [0]
# You will implement add_table and serve which are part of the Diner ADT
# Group ADT
def make_group (name):
Groups are represented by their name and their status."""
return [name, 'waiting']
||||||
def name (group):
return group [0]
def status (group):
return group [1]
def start_eating…
Chapter 12 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Ch. 12.1 - Suppose aList is an object of the class...Ch. 12.1 - Prob. 2STQCh. 12.1 - Prob. 3STQCh. 12.1 - Prob. 4STQCh. 12.1 - Can you use the method add to insert an element at...Ch. 12.1 - Prob. 6STQCh. 12.1 - Prob. 7STQCh. 12.1 - If you create a list using the statement...Ch. 12.1 - Prob. 9STQCh. 12.1 - Prob. 11STQ
Ch. 12.1 - Prob. 12STQCh. 12.2 - Prob. 13STQCh. 12.2 - Prob. 14STQCh. 12.2 - Prob. 15STQCh. 12.2 - Prob. 16STQCh. 12.3 - Prob. 17STQCh. 12.3 - Prob. 18STQCh. 12.3 - Prob. 19STQCh. 12.3 - Write a definition of a method isEmpty for the...Ch. 12.3 - Prob. 21STQCh. 12.3 - Prob. 22STQCh. 12.3 - Prob. 23STQCh. 12.3 - Prob. 24STQCh. 12.3 - Redefine the method getDataAtCurrent in...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.4 - Revise the definition of the class ListNode in...Ch. 12.4 - Prob. 30STQCh. 12 - Repeat Exercise 2 in Chapter 7, but use an...Ch. 12 - Prob. 2ECh. 12 - Prob. 3ECh. 12 - Repeat Exercises 6 and 7 in Chapter 7, but use an...Ch. 12 - Write a static method removeDuplicates...Ch. 12 - Write a static method...Ch. 12 - Write a program that will read sentences from a...Ch. 12 - Repeat Exercise 12 in Chapter 7, but use an...Ch. 12 - Write a program that will read a text file that...Ch. 12 - Revise the class StringLinkedList in Listing 12.5...Ch. 12 - Prob. 12ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 14ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 17ECh. 12 - Revise the method selectionSort within the class...Ch. 12 - Repeat the previous practice program, but instead...Ch. 12 - Repeat Practice Program 1, but instead write a...Ch. 12 - Write a program that allows the user to enter an...Ch. 12 - Write a program that uses a HashMap to compute a...Ch. 12 - Write a program that creates Pet objects from data...Ch. 12 - Repeat the previous programming project, but sort...Ch. 12 - Repeat the previous programming project, but read...Ch. 12 - Prob. 9PPCh. 12 - Prob. 10PPCh. 12 - Prob. 11PPCh. 12 - Prob. 12PPCh. 12 - Prob. 13PPCh. 12 - Prob. 14PPCh. 12 - Prob. 15PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
T F: The multiplication operator has higher precedence than the addition operator.
Starting Out With Visual Basic (7th Edition)
What is the difference between a Do-While loop and a Do-Until loop?
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Define a class for rational numbers. A rational number is a number that can be represented as the quotient of t...
Problem Solving with C++ (9th Edition)
What is an algorithm?
Starting Out With Visual Basic (8th Edition)
The ________ object is assumed to exist and it is not necessary to include it as an object when referring to it...
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Describe the three types of anomalies that can arise in a table and the negative consequences of each.
Modern Database Management
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
- Implement a new concat method in the String class you worked on for HW2. The method should return a new String object that represents the text you would end up with if the argument String were "added onto the end of" this String. For example, in the code below, the String object answer should represent the text "bookstore" and true should be printed the screen. char[] bookA = {'b', 'o', 'o', 'k'}; char[] storeA = {'s', 't', 'o', 'r', 'e'}; char[] bookstoreA = {'b', 'o', 'o', 'k', 's', 't', 'o', 'r', 'e'}; String book = new String(bookA); String store = new String(storeA); String bookstore = new String(bookstoreA); String answer = book.concat(store); System.out.println(answer.equals(bookstore)); In the text area below, type in your definition of the concat method. (In other words, type in the code that should replace the //TODO comment.) Your code cannot call any methods. public class String { private char[] data; public String(char[] value) { data = new…arrow_forwardYou can check whether a string is a substring of another string by using the find method in the str class. Write your own function to implementfind. Write a program that prompts the user to enter two strings and then checks whether the first string is a substring of the second string.arrow_forwardWrite a Class called ProblemALG007a to do the following: You must take in an input string parameter called text and look for pairs of strings in text, breaking the string up using spaces as the delimiter. There are two types of pairs that your program must find, combo-pairs and next-to-pairs, and you'll need to find a count of each. Next-to-pairs appear next to each other, while combo-pairs cover every combination that can be found of pairing the strings.arrow_forward
- Can you implement the Student class using the concepts of encapsulation? A solution is placed in the "solution" section to help you, but we would suggest you try to solve it on your own first. You are given a Student class in the editor. Your task is to add two fields: ● String name ● String rollNumber and provide getter/setters for these fields: ● getName ● setName ● getRollNumber ● setRollNumber Implement this class according to the rules of encapsulation. Input # Checking all fields and getters/setters Output # Expecting perfectly defined fields and getter/setters. There is no need to add constructors in this class.arrow_forwardPlease Use Java only. In this assignment, you will implement a simple class called CustomString. This class represents a more customizable version of a String, with additional attributes and methods. For example, the CustomString class has a “reverse” method which returns a new string version of the current string where the capitalization is reversed (i.e., lowercase to uppercase and uppercase to lowercase) for the alphabetical characters specified in a given argument. For CustomString “abc, XYZ; 123.”, calling reverse("bcdxyz@3210.") will return "aBC, xyz; 123.". The CustomString class also has a “remove” method which returns a new string version of the current string where the alphabetical characters specified in a given argument, are removed. For CustomString "my lucky numbers are 6, 8, and 19.", calling remove("ra6") will return "my lucky numbers e 6, 8, nd 19.". There are 5 methods that need to be implemented in the CustomString class: ● getString() - Returns the current…arrow_forwardJAVA Create a new class HashMapManipulation with a main method. Import the necessary classes from the java.util package, including the HashMap class. Create a HashMap object, named mapand use the put() method to add key-value pairs to the map. The keys are strings "A", "B", and "C", and the values are integers 1, 2, and 3 respectively. Use the size() method to print the size of the map. Use a for loop to print the key-value pairs in the map. The loop should iterate over the entries in the map using the entrySet() method, which will return a set of Map.Entry objects representing the key-value pairs in the map. The key and value of each entry are printed using the getKey() and getValue() methods, respectively. Use theget() method to get the value of key "A", and assigns it to a variable value. The value is then printed. Use the put() method to add a new key-value pair to the map. The key is "D" and the value is 4. The map is then printed again, to show the added key-value…arrow_forward
- You’ve been given a list of books to read over the summer, but you only want to read the books by a certain author. Write a method public List<Book> filterBooks(List<Book> readingList, String author) That takes a List of Books as a parameter, removes all Books from the readingList that are not written by the given author, then returns the resulting list. You can access the author of a Book by calling book.getAuthor(). The Book class is provided for reference. public List<Book> filterBooks(List<Book> readingList, String author){// Remove all Books from the readingList that are not// written by the given author. Return the resulting List for(int i = 0; i < readingList.size(); i++){//does current author == author?String currentBook = readingList.get(i);if(!currentBook.getAuthor().equals(author)){readingList.remove(i);i--;}}return readingList;} Book.java public class Book{private String title;private String author; public Book(String theTitle, String…arrow_forward1. Write a method called doubleListthat takes an ArrayList of strings as a parameter and replaces every string with two of that same string. For example, if the list stores the values ["how", "are", "you?"] before the method is called, it should store the values ["how", "how", "are", "are", "you?", "you?"] after the method finishes executing.In your program1, you also need to create a class namedProgram1.java, where you are going to construct some arralylists to test the doubleList within the static void main method. In the output, it will print out the original list and the new list after calling the doubleList method. 2.Write a method called filterRange that accepts an ArrayList of integers and two integer values min and max as parameters and removes all elements whose values are in the range min through max (inclusive). For example, if a variable calledlist stores the values [4, 7, 9, 2, 7, 7, 5, 3, 5, 1, 7, 8, 6, 7], the call of filterRange(list, 5, 7);should remove all values…arrow_forwardHonestly, I am struggling with my assignment here. I went to the teaching assistants and they told me that they still too are working through this problem. its harder to implement because I am a visual learner. import java.util.Scanner; public class Assignment03 { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); System.out.println("Voter ID List: "); String voterId = keyboard.nextLine(); System.out.println("Total number of votes: "); int totalVotes = keyboard.nextInt(); System.out.println("Votes for candidate 1: "); int candidate1Votes = keyboard.nextInt(); System.out.println("Votes for candidate 2: "); int candidate2Votes = keyboard.nextInt(); keyboard.close(); } }arrow_forward
- Write a class that would match a string. The class has method match with String as a return type. It accepts two inputs: the phrase/sentence string (text) and the pattern string (word). This method finds the first (or all) instances of the pattern in the text and changes that word in all uppercase and return the new phrase. Method countOccurence accepts a phrase/sentence and a pattern string and returns its number of occurrences. Add a main method that will allow the user to input the phrase/sentence and pattern. Call method match and countOccurence. See test case below. Sample Input: Text string: You will always have my love, my love, for the love I love is as lovely as love itself. Pattern string: love Output: New text: You will always have my LOVE, my LOVE, for the LOVE I LOVE is as lovely as LOVE itself. Number of occurrence: 5 For example: Input Result You will always have my love, my love, for the love I love is as lovely as love itself. love New text: You will…arrow_forwardImplement a “To Do” list. Tasks have a priority between 1 and 9, and a description (which you can come up with on your own, say, “wash dishes”). The program is going to prompt the user to enter the tasks by running the method add_priority_description, the program adds a new task and prints the current list with priority 1 tasks on the top, and priority 9 tasks at the bottom. The program will continue to ask the user if they want to add another tasks, and repeat the add_priority_description method, or enters Q to run the quit method to quit the program. Sample output (not limited to) 1. Study for the final 1. Take the final 2. Watch Justice League with friends 3. Play ball 9. Wash Dishes 9. Clean room. There is a possibility of two tasks having the same priority. If so, the last task that was entered gets to be printed first. Use HEAP in your solution.arrow_forward6. a. Fast in java coding please. Thank you 1. Why should you use StringBuffer objects instead of String objects in aprogram that makes lot of changes to strings?2. Each of the numeric wrapper classes has a static toString method. Whatdo these methods do?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
Java Math Library; Author: Alex Lee;https://www.youtube.com/watch?v=ufegX5o8uc4;License: Standard YouTube License, CC-BY