Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
6th Edition
ISBN: 9780134477367
Author: David J. Barnes, Michael Kolling
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 39E
Program Plan Intro
To remove all the tracks that contains specified Strings.
Write a program in BlueJ using Java and achieve the target of removing all the Tracks that contains the specified String as a parameter in the Music Organizer.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Pattern and Value are two strings that you must use. The pattern string, which denotes a pattern inside a string, is made up just of the letters a and b. For instance, the string catcatgocatgo matches the pattern aabab (where cat is represented by letter A and go by letter B). Additionally, it matches a, ab, and b pattern. To check whether a value matches a pattern, create a method.
Python:
Write a code snippet that imports the tkinter library and creates a new window object root.
Add a label widget to the window object root with the text "Hello, World!".
Write a code snippet that adds a button widget to the window object root with the text "Click me!", and binds the button to a function button_click() that prints "Button clicked!" to the console.
Hint: You may find the Label, Button, and command attributes in tkinter useful for completing parts 2 and 3
Note: For each part of the question, make sure to provide clear instructions and examples for the code snippets. Also, make sure to test your code snippets to ensure that they work as intended.
Write a program in Java called StringIndex.
Create a method called printIndex that passes your fullname as a parameter. Method should print each character of the String along with the index.
For example, if String parameter passed is “Kimberly”, the program should print:
0: K
1: I
2: m
3: b
4: e
5: r
6: l
7: y
Chapter 4 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Ch. 4 - Prob. 1ECh. 4 - What happens if you create a new MusicOrganizer...Ch. 4 - Prob. 3ECh. 4 - Prob. 4ECh. 4 - Write a declaration of a local variable called...Ch. 4 - Prob. 6ECh. 4 - Write assignments to the library, cs101. and track...Ch. 4 - If a collection stores 10 objects, what value...Ch. 4 - Write a method call using get to return the fifth...Ch. 4 - Prob. 10E
Ch. 4 - Write a method call to add the object held in the...Ch. 4 - Write a method call to remove the third object...Ch. 4 - Suppose that an object is stored at index 6 in a...Ch. 4 - Add a method called checklndex to the...Ch. 4 - Write an alternative version of checkIndex called...Ch. 4 - Rewrite both the 1istFi1e and removeFi1e methods...Ch. 4 - Prob. 17ECh. 4 - Prob. 18ECh. 4 - We know that the first file name is stored at...Ch. 4 - Prob. 20ECh. 4 - Create a MusicOrganizer and store a few file names...Ch. 4 - Create an ArrayList<String> in the Code Pad by...Ch. 4 - If you wish, you could use the debugger to help...Ch. 4 - Challenge exercise The for-each loop does not use...Ch. 4 - Prob. 25ECh. 4 - Prob. 26ECh. 4 - Prob. 27ECh. 4 - Write out the header of a for-each loop to process...Ch. 4 - Suppose we express the first version of the key...Ch. 4 - Write a while loop (for example, in a method...Ch. 4 - Write a while loop to add up the values 1 to 10...Ch. 4 - Write a method called sum with a while loop that...Ch. 4 - Challenge exercise Write a method isPrime (int n)...Ch. 4 - In the findFirst method, the loop's condition...Ch. 4 - Prob. 35ECh. 4 - Have the MusicOrganizer increment the play count...Ch. 4 - Prob. 37ECh. 4 - Prob. 38ECh. 4 - Prob. 39ECh. 4 - Prob. 40ECh. 4 - Complete the numberOfMembers method to return the...Ch. 4 - Prob. 42ECh. 4 - Prob. 43ECh. 4 - Prob. 44ECh. 4 - Challenge exercise Write a method to play every...Ch. 4 - Prob. 46ECh. 4 - Prob. 47ECh. 4 - Add a close method to the Auction class. This...Ch. 4 - Add a getUnsold method to the Auction class with...Ch. 4 - Suppose the Auction class includes a method that...Ch. 4 - Rewrite getLot so that it does not rely on a lot...Ch. 4 - Prob. 52ECh. 4 - Prob. 53ECh. 4 - Prob. 54ECh. 4 - Prob. 55ECh. 4 - Open the products project and complete the...Ch. 4 - Implement the findProduct method. This should look...Ch. 4 - Implement the numberInStock method. This should...Ch. 4 - Prob. 59ECh. 4 - Challenge exercise Implement a method in...Ch. 4 - Java provides another type of loop: the do-while...Ch. 4 - Prob. 85ECh. 4 - Prob. 86ECh. 4 - Find out about Java's switch-case statement. What...
Knowledge Booster
Similar questions
- Write a program in qt creator that asks the user to enter a temperature in Celsius, and then computes and displays the equivalent Fahrenheit temperature. It should use a QInputDialog to get the value from the user, and a QMessageBox to display the result.arrow_forwardAdd the code to the end of your monitorLevels() method. It must become the last code of monitorLevels(). Study the comments and complete the code # Loop through displayList for i in range(0,len(displayList)): # Test if the first item in the current sub-list contains the text "Price Level" # Tip: Remember that each sub-list is a list within a list (displayList). So you have # to access its items via displayList followed by TWO indexes. . . . # Extract the second item from the current sub-list into a variable called priceLevel priceLevel = . . . # Test if priceLevel is between previousPrice and currentPrice OR # priceLevel == previousPrice OR # priceLevel == currentPrice if( . . . ): # Sound the alarm. Pass in the frequency and duration.…arrow_forwardCreate a code that tracks how many times a phrase appears in a string. A number should be the function's output value. Never presume that a series of words can contain punctuation and only one space between words. Create the method so that it accepts a String argument or a StringBuilder object as a parameter.arrow_forward
- In some cases, a class depends on itself. That is, an object of one class interactswith another object of the same class. To accomplish this, a method of the classmay accept as a parameter an object of the same class.The concat method of the String class is an example of this situation. Themethod is executed through one String object and is passed another String object as a parameter. Here is an example:str3 = str1.concat(str2);The String object executing the method (str1) appends its characters to thoseof the String passed as a parameter (str2). A new String object is returned asa result and stored as str3. Write java code to implement given conditionsarrow_forwardExercise 1 - Number Guessing Game Make a new Java Project called Lab2. Within it, add a new class with the main method called NumberGuessGame. Inside the main method, implement a number guessing game, which will work by generating a pseudorandom number in the range of 0 to 100 (inclusive, so both 0 and 100 should be possible), then asking the user to enter a number that will be their guess. If the two match, display an appropriate message. Otherwise, display either "greater" or "lesser", depending on whether the pseudorandom number is greater than or less than the number entered.arrow_forwardSetup Instructions: Create a new class named Lab4 in the edu.ben.labs.lab4 package of your CMSC200 Java Project. Problem Set: Let's place a marker on the circle numbered 1 in the grid below. Then we will toss a coin. If the coin toss resulted in a 'heads', we would move the marker along the path labeled 'H' to the circle numbered 5. If the coin toss resulted in a 'tails', we would move the marker along the path labeled T' to the circle numbered 4. Now we would toss the coin again and move the marker accordingly. This is repeated for any number of coin tosses. The purpose of this problem is to simulate this automata and to report 2 3 the number of the circle on which the marker ends after a series of coin tosses. The marker always begins on the circle numbered 1. 7 Iпрut: Your program should accept a string consisting only of the characters 'h' or t, where each character represents the outcome of a coin toss ('h' - heads, 't - tails). The string is terminated by a #' character. Each…arrow_forward
- The zoo will have several animals, and each animal will have a name, age, and species. Moreover, each animal will have a method make_sound(), which should return a string representing the sound it makes. Perform the following steps: Create a Zoo class. This class should be able to store multiple animals. It should have methods to add_animal and remove_animal. Also, add a method get_animals that prints a list of all animals currently in the zoo, including their name, age, and species. Create an Animal parent class. This class should have attributes for name, age, and species. Include a make_sound() method that returns a string representing the sound the animal makes. Create two or more child classes that inherit from Animal (for example, Lion and Elephant - you get to choose the animal types). These child classes should override the make_sound() method to return a sound specific to the animal they represent. Your program should be interactive. It should provide a menu to the user that…arrow_forwardwhen coding a chess game, implement the following method: isInCheck(Side s): Returns true if the king of side s is attacked by any of the opponent’s pieces, i.e., if in the current board state, any of the opponents pieces can move to where the king is. Otherwise, it returns false. Note that this method is only used to warn the player when they are in check. You can use the GUI to test if this is working. public boolean isInCheck(Side side) { // TODO write this method return false; } public enum Side { BLACK, WHITE; public static Side negate(Side s) { return s == Side.BLACK ? Side.WHITE : Side.BLACK; } }arrow_forwardJAVAA7-Write a class with a constructor that accepts a String object as its argument. The class should have a method that returns the number of vowels in the string, and another method that returns the number of consonants in the string. Demonstrate the class in a program by invoking the methods that return the number of vowels and consonants. Print the counts returned.arrow_forward
- Q2 Create MusicOrganizer project using BlueJ . (i) Create a MusicOrganizer class and declare an ArrayList for storing the file names of music files into the String object. (ii) Create a constructor for the music organizer class and assign the field to the ArrayList. (iii) Write a method to add a file to the collection. (iv) Write a method to return the number of files in the collection. (v) Write a method to remove a file from the collection. (vi) Make a screen shot of the coding and output.arrow_forwardImplement the "Add song" menu item. New additions are added to the end of the list. Ex: ADD SONG Enter song's unique ID: SD123 Enter song's name: Peg Enter artist's name: Steely Dan Enter song's length (in seconds): 237arrow_forwardUse a TextArea, and its setText() and append() methods to write an application that allows the user to select options for a dormitory room. Use CheckBoxes for options such as private room, Internet connection, cable TV connection, microwave, refrigerator, and so on. When the application starts, use a text area to display an appropriate message. After the user has selected the desired options, replace the message in the text area so it displays a running list of the user’s choices.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT