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 38E
Program Plan Intro
To select and play a song in media player.
Program Plan:
Write a program in BlueJ using Java and achieve the method to stop the song in the player and to play the current selected song.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Implement the following:
Write a loop that prints out the following numbers.
Make sure to precisely match the output format below.Write your code in the ANSWER area provided below (must include comments if using code is not covered in the course).
Example Output8 15 22 29 36 43 50 57 64 71 78
Remember the game of FizzBuzz from the last time? Well, I thought of some changes in the game, and also with the help of loops as well. Firstly, you'll be asking for a random integer and then loop from 1 until that integer. Then, implement these conditions in the game:
print "Fizz" if the number is divisible by 3
print "Buzz" if the number is divisible by 5
print "FizzBuzz" if the number is divisible by both 3 and 5
print the number itself if none of the above conditions are met
Input
A line containing an integer.
15
Output
Multiple lines containing a string or an integer.
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
Please do it with comments.
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
- A word is called as a good word if all the letters of the word are distinct. That is, all the letters of the word are different from each other letter. Else, the word is called as a bad word. This can be continued based on the user input is 'Y'.arrow_forwardWhat value is returned if you get the machine’s balance after it has printed a ticket?arrow_forwardYou have 1000 bottles of soda, and exactly one is poisoned. You have 10 test strips which can be used to detect poison. A single drop of poison will turn the test strip positive permanently. You can put any number of drops on a test strip at once and you can reuse a test strip as many times as you'd like (as long as the results are negative). However, you can only run tests once per day and it takes seven days to return a result. How would you figure out the poisoned bottle in as few days as possible?Follow up: Write code to simulate your approacharrow_forward
- Print numbers 0, 1, 2, ..., userNum as shown, with each number indented by that number of spaces. For each printed line, print the leading spaces, then the number, and then a newline. Hint: Use i and j as loop variables (initialize i and j explicitly). Note: Avoid any other spaces like spaces after the printed number. Ex: userNum = 3 prints: 0 1 2 3arrow_forwardWhy should you be careful not to place a statement in the body of a For...Nextloop that changes the value of the loop’s counter variable?arrow_forwardWrite a program that displays an inchworm on the left-hand side of the screen, facing right. Then slowly move him across the screen, until he disappears off the right-hand side. You may wish to do this in a loop so that after disappearing to the right, the worm appears again on the left. The diagram below shows how he may look at various points on the screen. 00 00 000 00 00 00 -000000000 -0000 0000 -000 000 -0000 0000 -000000000 Please do it C++, and show the output as well, thank youarrow_forward
- (THIS IS FOR CENGAGE MINDTAP. HIGHLY RECOMMEND USING THIS. IF ISSUE OCCUR, USE DEVC++ 5.11) Instructions Jason opened a coffee shop at the beach and sells coffee in three sizes:small (9 oz),medium (12 oz),and large (15 oz). The cost of one small cup is $1.75, one medium cup is $1.90, and one large cup is $2.00. Write a menu-driven program that will make the coffee shop operational. Your program should allow the user to do the following: Buy coffee in any size and in any number of cups. At any time show the total number of cups of each size sold. At any time show the total amount of coffee sold. At any time show the total money made. Your program should consist of at least the following functions: a function to show the user how to use the program; a function to sell coffee; a function to show the number of cups of each size sold; a function to show the total amount of coffee sold; and a function to show the total money made. Your program should not use any global variables and…arrow_forwardPlease prompts/labeling the input and output. For better understandingarrow_forwardChange your previous temperature conversion program so that it willconverts the temperatures from 1 to 50 Celsius to Fahrenheit and Kelvin. The outputshould look like this:Celsius Fahrenheit Kelvin1 33.8 274.152 35.6 275.153 37.4 276.154 38.2 277.15This continues up to 50.arrow_forward
- Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example output for userNum = 40:20 10 5 2 1 Note: These activities may test code with different test values. This activity will perform four tests, with userNum = 40, then with userNum = 2, then with userNum = 0, then with userNum = -1. See "How to Use zyBooks".Also note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message.arrow_forwardWrite a program (or modify the one written for Lab 2) that displays the following menu and prompts the user for a selection. Once the selection has been made, display the selection back to the user. Then, ask the user for two numbers and perform the selected operation (+, -, *, /). Display the results back to the user (e.g. 2 + 3 = 5). When dividing, display an error message if the second number (denominator) is 0. 1) Add two numbers 2) Subtract two numbers 3) Multiply two numbers 4) Divide two numbers 9) Exit program The program should: contain header comments as shown in class display a "hello" message before presenting the menu display the menu prompt the user for selection display the selection back to the user if the selection was invalid, display error message to user and then go to goodbye message if the selection was valid, prompt the user for two numbers if the operation is division, and the second number is 0, display error message to user and then go to goodbye message…arrow_forwardWrite a program (or modify the one written for Lab 2) that displays the following menu and prompts the user for a selection. Once the selection has been made, display the selection back to the user. Then, ask the user for two numbers and perform the selected operation (+, -, ", /). Display the results back to the user (e.g. 2+3 = 5). When dividing, display an error message if the second number (denominator) is 0. 1) Add two numbers 2) Subtract two numbers 3) Multiply two numbers 4) Divide two numbers 9) Exit program The program should: • contain header comments as shown in class • display a "hello" message before presenting the menu • display the menu • prompt the user for selection • display the selection back to the user • if the selection was invalid, display error message to user and then go to goodbye message • if the selection was valid, prompt the user for two numbers • if the operation is division, and the second number is 0, display error message to user and then go to goodbye…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