All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Ask a Question
Search
Search
Sign In
Register
study help
computer science
java how to program late objects
Questions and Answers of
Java How To Program Late Objects
Modify the DrawStars example so that all the stars have Rotate transition animations that execute indefinitely—that is, set each animation’s cycle count to Animation.INDEFINITE.DrawStars example
Rewrite the Account class to store the balance as a BigDecimal object and to perform all calculations using BigDecimals.Account class 2 3 4 5 6 7 // Fig. 7.8: Account.java // Account class with a
Use inheritance to create an exception superclass (called ExceptionA) and exception subclasses ExceptionB and ExceptionC, where ExceptionB inherits from ExceptionA and ExceptionC inherits from
The Tip Calculator app does not need a Button to perform its calculations. Reimplement this app to use property listeners to perform the calculations whenever the user modifies the bill amount or
Use a HashMap to create a reusable class for choosing one of the 13 predefined colors in class Color. The names of the colors should be used as keys, and the predefined Color objects should be used
Use SecureRandom method ints to generate a stream of 50 random numbers in the range 1 to 999, then filter the resulting stream elements to select only the odd numbers and display the results in
Provide the inorder, preorder and postorder traversals of the binary search tree of Fig. 21.18.Fig. 21.18 18 11 19 28 40 49 71 32 44 69 72 83 97 92 99
Write a program that concatenates two linked-list objects of characters. Class ListConcatenate should include a static method concatenate that takes references to both list objects as arguments and
Write a program that inserts 25 random integers from 0 to 100 in order into a linked-list object. For this exercise, you’ll need to modify the List class (Fig. 21.3) to maintain an ordered list.
Modify the SortedList class from Exercise 21.7 to include a merge method that can merge the SortedList it receives as an argument with the SortedList that calls the method. Write an application to
Write an application that reads a list of integers and stores them in a linked list. Write a method that identifies and prints the position at which the list is no longer sorted in an increasing
Write a program that inputs six numbers in ascending order and uses a stack to print these numbers in descending order.
Write a program that uses a stack to determine whether a string is a palindrome (i.e., the string is spelled identically backward and forward). The program should ignore spaces and punctuation.
Stacks are used by compilers to help in the process of evaluating expressions and generating machine-language code. In this and the next exercise, we investigate how compilers evaluate arithmetic
Write class PostfixEvaluator that evaluates a postfix expression such as 6 2 + 5 * 8 4 / -The program should read a postfix expression consisting of digits and operators into a StringBuffer. The
Modify the postfix evaluator program of Exercise 21.13 so that it can process integer operands larger than 9.Exercise 21.13Write class PostfixEvaluator that evaluates a postfix expression such as 6 2
Write a program that simulates a checkout line at a supermarket. The line is a queue object. Customers (i.e., customer objects) arrive at random integer intervals of from 1 to 4 minutes. Also, each
Modify Figs. 21.15 and 21.16 to allow the binary tree to contain duplicates.Fig. 21.15Fig. 21.16 I // Fig. 21.15: Tree.java 2 // TreeNode and Tree class declarations for a binary search tree. 3
Write a program based on the program of Figs. 21.15 and 21.16 that inputs a line of text, tokenizes it into separate words, inserts the words in a binary search tree and prints the inorder, preorder
Modify Figs. 21.15 and 21.16 so the Tree class provides a method getDepth that determines how many levels are in the tree. Test the method in an application that inserts 20 random integers into a
Modify the List class of Fig. 21.3 to include method printListBackward that recursively outputs the items in a linked-list object in reverse order. Write a test program that creates a list of
Modify the List class of Fig. 21.3 to include method search that recursively searches a linked-list object for a specified value. The method should return a reference to the value if it’s found;
In this exercise, we discuss deleting items from binary search trees. The deletion algorithm is not as straightforward as the insertion algorithm. Three cases are encountered when deleting an
Modify class Tree of Fig. 21.15 to include method contains, which attempts to locate a specified value in a binary-search-tree object. The method should take as an argument a search key to locate. If
The program of Figs. 21.15 and 21.16 illustrated three recursive methods of traversing a binary tree—inorder, preorder and postorder traversals. This exercise presents the level-order traversal of
Modify class Tree of Fig. 21.15 to include a recursive outputTree method to display a binary tree object. The method should output the tree row by row, with the top of the tree at the left of the
Our linked-list class allowed insertions and deletions at only the front and the back of the linked list. These capabilities were convenient for us when we used composition to produce a stack class
As presented in the text, linked lists must be searched sequentially. For large lists, this can result in poor performance. A common technique for improving list-searching performance is to create
Create an app in which, as the user moves the mouse cursor around the window, a Circle and Polyline follow the cursor. The app should appear as shown in Fig. 22.18 . There should always be a Circle
Create a UsingGradients app that displays a Rectangle and enables the user to fill it with a radial or a linear gradient. The app should enable users to modify either gradient by specifying the RGBA
Create an art app similar to the Painter app so that allows you to draw shapes by clicking and dragging the mouse in a Canvas. Include options for:a) Selecting the shape to draw—line, rectangle or
Create an art app similar to the Painter app so that allows you to draw shapes by clicking and dragging the mouse in a Pane and adding an appropriate Shape object to the scene graph. Include options
Write an app that continuously draws shapes of your choosing on a Canvas. Use random positions, sizes, locations, line widths, fills and alpha transparencies. The shapes should randomly move around
Write an app that continuously displays Shape subclass objects on a Pane with random sizes, locations, stroke widths, fills and alpha transparencies. The Shapes should randomly move around the Canvas
Using the techniques create an app that continuously displays Boxes, Cylinders and Spheres on a Pane with random sizes, locations and diffuse colors. For each three-dimensional shape, create an
JavaFX supports lighting and camera effects. The classes for these are AmbientLight, PointLight, ParallelCamera and PerspectiveCamera (package javafx.scene). Investigate each of these classes, then
Recreate the classic word game Hangman. At the start of the game, display a dashed line with one dash representing each letter in the word to be guessed. As a hint to the user, provide either a
Use the bouncing-ball animation techniques to create a Block Breaker game witha) A bouncing ball (a Circle),b) Several rows and columns of blocks (Rectangles) in red, yellow, blue or green
Modify the Block Breaker game in Exercise 22.13 as follows:a) When the ball hits the paddle, change its dx value and direction based on the intersection point. For example, assume the paddle has
Create a grid of letters that fills the screen. Hidden in the grid should be at least ten words. The words may be horizontal, vertical or diagonal, and, in each case, forward, backward, up or down.
Using the animation techniques you learned in this chapter, modify the fractal app to animate the Lo fractal. Provide options that allow the user to specify the number of levels, then animate the
Create an app that simulates a kaleidoscope. Allow the user to click a Button to clear the screen and draw another kaleidoscope image.
Research the Game of Snake online and develop an app that allows a user to play the game.
Create an app that displays a digital clock on the screen in a Label. Include alarm-clock functionality. Use a Timeline animation that executes once per second.
Create an app that displays an analog clock with hour, minute and second hands that move appropriately as the time changes. Use an AnimationTimer and scale the movement of the second hand based on
The recursive Towers of Hanoi. Write a animated solution to the Towers of Hanoi that shows the disks moving between pegs. Allow the user to enter the number of disks.
Display a Label containing the phrase "JavaFX" and apply a drop shadow to the text. Investigate the JavaFX CSS function dropshadow at https://
Create shapes with a variety of linear and radial gradients. Investigate the JavaFX CSS gradient capabilities at https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html.
Create an app that displays a rectangle with a shadow and allows the user to control the shadow using Sliders. Investigate class DropShadow (package javafx.scene.effect). Use Node method setEffect to
Write an app that draws eight concentric circles in a Canvas. For each new circle, increase the radius value by 5 pixels. Choose the circles’ colors, randomly.
Write an app that converts a color image in an ImageView to SepiaTone (package javafx.scene.effect).
Suppose an image is displayed on a Canvas. One way to erase the image is simply to set every pixel to the same color immediately, but the visual effect is dull. Write an app that displays an image,
Create an app that scrolls dotted characters from right to left (or from left to right if that’s appropriate for your language) across a marquee-like display sign. As an option, display the text in
Create an app that scrolls a series of images across a marquee screen on a Canvas.
Develop a multimedia simulation of a “one-armed bandit.” Have three spinning wheels. Place symbols and images of various fruits on each wheel. Use random-number generation to simulate the
Create a multimedia-based simulation of the game of pool. Each player takes turns using the mouse to position a pool cue and hit it against the ball at the appropriate angle to try to make other
Create an app that enables the user to play the game of 15. The game has a 4-by-4 board with a total of 16 slots. One slot is empty; the others are occupied by 15 square tiles numbered 1 through 15.
You’ve probably had your eyesight tested. In these exams, you’re asked to cover one eye, then read out loud the letters from an eyesight chart called a Snellen chart. The letters are arranged in
The SpotOn game tests a user’s reflexes by requiring the user to click moving spots before they disappear (Fig. 22.19 ). All of the required images and sounds for this exercise are located in the
Amusement parks have many variations of the horse race in whichyour horse moves in response to your rolling balls into a hole, hitting a target with a water gun, etc.Modify the SpotOn game in
This game requires some twodimensional analytic geometry and some basic trigonometry to determine the angle of the cannon.The Cannon game app challenges you to destroy nine targets before a
Reimplement Exercise 22.36. using Circles and Rectangles to represent the game elements and TransitionAnimations to move them. Class Shape provides static method intersect that can be used for
Add the following Cannon game enhancements and others of your choosing:a) Add an “explosion animation” each time the cannonball hits one of the targets. Match the animation with the “explosion
State whether each of the following is true or false. If false, explain why.a) Timed waiting threads return to the runnable state only when the time interval expires.b) With synchronized, there is no
Define each of the following terms.a) Blocked stateb) Thread schedulingc) Quantumd) Thread confinemente) Atomic operationf) Indefinite postponement g) monitor lock h) thread priority.
What is the difference between the following pairs?a) Deadlock—starvationb) Wait—sleepc) Concurrency—parallelismd) Ready—runnablee) Notify—notifyAllf) Waiting state—timed waiting
Write a program that uses the JavaFX threading techniques introduced in this chapter to bounce a blue ball inside a Pane. The ball should begin moving in a random direction from the point where the
Modify the program in Exercise 23.10 to add a new ball each time the user clicks the mouse. Provide for a minimum of 20 balls. Randomly choose the color for each new ball.Exercise 23.10Write a
Modify the program in Exercise 23.11 to add shadows. As a ball moves, draw a solid black oval at the bottom of the Pane. You may consider adding a 3-D effect by increasing or decreasing the size of
Compare the use of synchronization vis-à-vis ReentrantLock for controlling access to shared objects.
Describe how a highway off-ramp onto a local road is a good example of a producer/consumer relationship with a bounded buffer. In particular, discuss how the designers might choose the size of the
Reimplement Fig. 17.22 using parallel streams. Use the Date/Time API timing techniques to compare the time required for the sequential and parallel versions of the program.Fig. 17.22 12345 2 3 4 13
Reimplement Exercise 17.10 using parallelstreams. Use the Date/Time API timing techniques to compare the time required for the sequential and parallel versions of the program.Exercise 17.10Modify
Reimplement Exercise 17.11 using parallel streams. Use the Date/Time API timing techniques to compare the time required for the sequential and parallel versions of the
In Fig. 17.24 , we implemented a stream pipeline that rolled a die 60,000,000 times using values produced by SecureRandom method ints.Use the same timing techniques you used in Exercise 17.25 to time
Used map and sum to calculate the sum of the squares of an IntStream’s values. Reimplement stream pipeline in Fig. 17.9 to replace map and sum with the following reduce, which receives a lambda
Demonstrated the recursive merge sort algorithm. Reimplement the program of Fig. 19.6 using the Fork/Join Framework.Fig. 19.6 I // Fig. 19.6: MergeSortTest.java // Sorting an array with merge sort.
In Exercise 19.10 , you implemented the recursivequicksort algorithm. Reimplement the quicksort using the Fork/Join Framework.Exercise 19.10The basic algorithm seems simple enough, but how do we
In Exercises 23.20–23.21, you reimplemented recursive sorting algorithms using the Fork/Join Framework. Why might you not want to invest the effort into applying this technique to a recursive
Using the techniques shown in this chapter, define a complete query application for the books database. Provide the following predefined queries:a) Select all authors from the Authors
Define a data-manipulation application for the books database. The user should be able to edit existing data and add new data to the database (obeying referential and entity integrity constraints).
We introduced an employee-payroll hierarchy to calculate each employee’s payroll. In this exercise, we provide a database of employees that corresponds to the employee-payroll hierarchy. (A SQL
Modify Exercise 24.4 to provide a ComboBox and a TextArea to allow the user to perform a query that is either selected from the ComboBox or input into the TextArea. Sample predefined queries should
Modify Exercise 24.5 to perform the following tasks:a) Increase base salary by 10% for all base-plus-commission employees.b) If the employee’s birthday is in the current month, add a $100 bonus.c)
Modify the program to include a method named updatePerson in class PersonQueries. The method should update an existing entry in the database. Provide an Update Button. When the user presses this
Modify the program of Exercise 24.7 to include a method named deletePerson in class PersonQueries. The method should delete an existing entry in the database. Provide a Delete Button. When the user
Modify the optional ATM Case Study (located with this book’s online chapters—see the inside front cover of the book) to use an actual database to store the account information. We provide a SQL
Confirm that when you use System.out.println to display a String literal, such as "Happy Birthday!", the quotes ("") are not displayed. End your statement with a semicolon.
Repeat Exercise 25.1, but remove the semicolon at the end of your statement to demonstrate that semicolons in this position are optional in JShell.Exercise 25.1Confirm that when you use
Confirm that JShell does not execute a // end-of-line comment.
Show that an executable statement enclosed in a multiline comment—delimited by /* and */—does not execute.
Show what happens when the following code is entered in JShell:/* incomplete multi-line comment System.out.println(“Welcome to Java Programming!”)/* complete multi-line comment */
Show that indenting code with spaces does not affect statement execution.
Declare each of the following variables as type int in JShell to determine which are valid and which are invalid?a) Firstb) First numberc) First1d) 1first.
Show that braces do not have to occur in matching pairs inside a string literal.
Show what happens when you type each of the following code snippets into JShell:a) System.out.println("seems OK")b) System.out.println("missing something?)c) System.out.println"missing something
Demonstrate that after a System.out.print the next print results appear on the same line right after the previous one’s. To demonstrate this, reset the current session, enter two System.out.print
Demonstrate that after a System.out.println, the next text that prints displays its text at the left of the next line. To demonstrate this, reset the current session, enter a System.out.println
Demonstrate that you can reset a JShell session to remove all prior snippets and start from scratch without having to exit JShell and start a new session.
Using System.out.println, demonstrate that the escape sequence causes a newline to be issued to the output. Use the string"WelcometoJShell!"
Showing 1 - 100
of 421
1
2
3
4
5