Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 14, Problem 14.27PE
Program Plan Intro
Draw a detailed clock
Program Plan:
- Import required packages.
- Define the main class “E27” that extends the “Application” class.
- The method “start ()” overrides the start method in the “Application” class.
- Create a clock pane
- Create a string to display the time.
- Add the created string to the label.
- Create a border pane and set it to center.
- Set the label at the bottom.
- Create a scene and place it on the stage.
- Display the stage using “show ()” method.
- Define the “main ()” method.
- Launch the application.
- Create a class “DetailedClockPane” that extends Pane.
- Declare required parameters for the clock.
- Define the constructor with no parameters.
- Get the current time.
- Define the constructor with three parameters.
- Set the hour, minute and second.
- Use accessors and mutators methods to get and set the hour, minute and seconds.
- Set the current hour, minute and seconds inside the function “setCurrentTime ()”.
- Finally call the function “paintClock ()”.
- Give function definition for “paintClock ()”.
- Initialize the clock parameters.
- Create a circle using “new Circle ()”.
- Set the color and stroke color for the circle.
- Set the length to draw second’s hand.
- Draw the second hand by creating a line using “new Line ()”.
- Set the stroke color.
- Set the length to draw minute’s hand.
- Draw the minute hand by creating a line using “new Line ()”.
- Set the stroke color.
- Set the length to draw hour’s hand.
- Draw the hour hand by creating a line using “new Line ()”.
- Set the stroke color.
- Now, clear the pane using “clear ()” method.
- Add the circle and three lines to the pane.
- Add more details to the clock.
- Use “for” loop to display hours on the clock.
- Give function definition for “setWidth ()” to set width.
- Set the width of the pane.
- Call the function “paintClock ()”.
- Give function definition for “setHeight ()” to set height.
- Set the height of the pane.
- Call the function “paintClock ()”.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
(YOU ARE NOT ALLOWED TO USE ARRAYLIST IN THIS PROJECT)Write a Java program to simulate a blackjack game of cards. The computer will play the role of the dealer. The program will randomly generate the cards dealt to the player and dealer during the game. Cards in this game will be represented by numbers 1 to 13 with Ace being represented by a 1. Remember, that face cards (i.e. Jack, Queen, and King) are worth 10 points to a hand while an Ace can be worth 1 or 11 points depending on the user’s choice. The numbered cards are worth their number value to the hand.
(Convert decimals to fractions)Write a program that prompts the user to enter a decimal number and displays the number in a fraction.Hint: read the decimal number as a string, extract the integer part and fractional part from the string, and use the Rational class in LiveExample 13.13 to obtain a rational number for the decimal number. Use the template athttps://liveexample.pearsoncmg.com/test/Exercise13_19.txt
The problem can not use BigInteger
//Below is the Rational LiveExample 13.13 that goes with the problem/question; notice "long" instead of "BigInteger"
class Rational extends Number implements Comparable<Rational> { // Data fields for numerator and denominator private long numerator = 0; private long denominator = 1;
/** Construct a rational with default properties */ public Rational() { this(0, 1); }
/** Construct a rational with specified numerator and denominator */ public Rational(long numerator, long denominator) { long gcd = gcd(numerator,…
(Convert decimals to fractions) Write a program that prompts the user to enter a decimal number and displays the number in a fraction. Hint: read the decimal number as a string, extract the integer part and fractional part from the string, and use the Rational class to obtain a rational number for the decimal number. Sample Run 1Enter a decimal number: 3.25 The fraction number is 13/4 Sample Run 2Enter a decimal number: -0.45452 The fraction number is -11363/25000
Chapter 14 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 14.2 - Explain the evolution of Java GUI technologies.Ch. 14.2 - Prob. 14.2.2CPCh. 14.3 - Prob. 14.3.1CPCh. 14.3 - Show the output of the following JavaFX program:...Ch. 14.4 - How do you create a Scene object? How do you set a...Ch. 14.4 - Prob. 14.4.2CPCh. 14.4 - Prob. 14.4.3CPCh. 14.4 - How do you replace the code in lines 20 and 21 in...Ch. 14.5 - Prob. 14.5.1CPCh. 14.5 - Prob. 14.5.2CP
Ch. 14.5 - Can you create an object of IntegerProperty using...Ch. 14.5 - Prob. 14.5.4CPCh. 14.6 - Prob. 14.6.1CPCh. 14.6 - Prob. 14.6.2CPCh. 14.7 - How do you create a color? What is wrong about...Ch. 14.7 - Prob. 14.7.2CPCh. 14.7 - Prob. 14.7.3CPCh. 14.8 - Prob. 14.8.1CPCh. 14.8 - Prob. 14.8.2CPCh. 14.9 - Prob. 14.9.1CPCh. 14.9 - Prob. 14.9.2CPCh. 14.9 - Prob. 14.9.3CPCh. 14.10 - Prob. 14.10.1CPCh. 14.10 - Prob. 14.10.2CPCh. 14.10 - Prob. 14.10.3CPCh. 14.10 - Prob. 14.10.4CPCh. 14.10 - Prob. 14.10.5CPCh. 14.11 - How do you display a text, line, rectangle,...Ch. 14.11 - Prob. 14.11.2CPCh. 14.11 - Prob. 14.11.3CPCh. 14.11 - Write code fragments to fill red color in a...Ch. 14.11 - Prob. 14.11.5CPCh. 14.11 - Prob. 14.11.6CPCh. 14.11 - Write code fragments to display the outline of the...Ch. 14.11 - Write code fragments to display the lower half of...Ch. 14.11 - Write code fragments to display a polygon...Ch. 14.11 - Write code fragments to display a polygon...Ch. 14.11 - Prob. 14.11.11CPCh. 14.12 - Prob. 14.12.1CPCh. 14 - Prob. 14.1PECh. 14 - Prob. 14.2PECh. 14 - (Display three cards) Write a program that...Ch. 14 - (Color and font) Write a program that displays...Ch. 14 - (Characters around circle) Write a program that...Ch. 14 - Prob. 14.6PECh. 14 - (Display random 0 or 1) Write a program that...Ch. 14 - (Create four fans) Write a program that places...Ch. 14 - (Display a cylinder) Write a program that draws a...Ch. 14 - Prob. 14.11PECh. 14 - (Display a bar chart) Write a program that uses a...Ch. 14 - Prob. 14.13PECh. 14 - (Display a rectanguloid) Write a program that...Ch. 14 - Prob. 14.15PECh. 14 - Prob. 14.16PECh. 14 - (Game: hangman) Write a program that displays a...Ch. 14 - Prob. 14.18PECh. 14 - (Plot the sine and cosine functions) Write a...Ch. 14 - (Draw an arrow line) Write a static method that...Ch. 14 - Prob. 14.21PECh. 14 - (Connect two circles) Write a program that draws...Ch. 14 - (Geometry: two rectangles) Write a program that...Ch. 14 - (Geometry: Inside a polygon?) Write a program that...Ch. 14 - Prob. 14.25PECh. 14 - Prob. 14.27PECh. 14 - (Random time) Modify the ClockPane class with...Ch. 14 - (Game: bean machine) Write a program that displays...
Knowledge Booster
Similar questions
- (Written in Java or Python) Write a program that allows a user to select 3 points on a graphics panel. Then, draw a triangle using these 3 points. Allow the user to specify a number of random points to be generated inside of the triangle. For each random point that is within the boundaries of the triangle draw a small dot at each of the points that are halfway between the randomly generated point and each vertex of the triangle. Do not draw the randomly generated point. Allow the user to repeat the process without removing the old dots. Allow the user to clear the screen.arrow_forward(Rectangle Class) Create a class Rectangle with attributes lengthand width, each of which defaults to 1. Provide methods that calculatethe rectangle’s perimeter and area. It has set and get methods for bothlength and width. The set methods should verify that length andwidth are each floating-point numbers larger than 0.0 and less than 20.0.Write a program to test class Rectangle.(Java Programming Language)arrow_forward(No java code/drawing) 1. Show the BST after inserting 15, 43, 100, 34, 23, 3, and 60 into an empty BST. 2. Show the BST after deleting 15 from the following BST. 3. Show the BST after deleting 60 from the following BST. 4. Show the inorder, preorder, and postorder of the following BST.arrow_forward
- (Intro to Java) Open up Eclipse and create a new Java class called Salary.java. Copy and paste the starter code below into the file. NOTE: Do not change the starter code! All you need to do is add to it. import java.util.Scanner; public class Salary { //Write your methods here public static void main(String[] args) { Scanner input = new Scanner(System.in);int hours;double hourly_wage;double weekly_salary = 0;double monthly_salary = 0;double yearly_salary = 0;System.out.println("This program will calculate your weekly, monthly "+ "and yearly salary!");System.out.print("Please enter your hourly wage: ");hourly_wage = input.nextDouble();System.out.print("Please enter the number of hours you work each week: ");hours = input.nextInt();//call methods belowweekly_salary = //method call goes heremonthly_salary = //method call goes hereyearly_salary = //method call goes hereSystem.out.printf("You make $%.2f per week\n", weekly_salary);System.out.printf("You make $%.2f per month\n",…arrow_forward(IllegalArgumentException)Programming defined the Triangle class with three sides. In the a triangle the sum of any two sides is greater then than the other side. Create IllegaTriangleException class, and modify the constructor of Triangle classto throw an IllegaTriangleException object if a triangle is created with sides that violate the rule, as follows: /** Construct a tringle the specified sides*/ public Triangle(double side1, double side2, double side3) throws IllegaTriangleException{ //Implementarrow_forward(Area and perimeter of a rectangle) Write a program that displays the area and perimeterof a rectangle with a width of 5.3 and height of 8.6 using the following formula:area = width X heightperimeter = 2 X (width + height)arrow_forward
- (It must be done on python) Create a “Rectangle” class, which is a geometric figure. The rectangle must have two attributes: “side1” and “side2” and methods that calculate area and perimeter must be implemented.Also define a class “Square”, which is an equal-sided rectangle.arrow_forward(Geometry: MyRectangle2D class) Define the MyRectangle2D class that contains: Two double data fields named x and y that specify the center of the rectangle with getter and setter methods. (Assume the rectangle sides are parallel to the x- or y-axis.) The data fields width and height with getter and setter methods. A no-arg constructor that creates a default rectangle with (0, 0) for (x, y) and 1 for both width and height. A Constructor that creates a rectangle with the specified x, y, width, and height. A method getArea() that returns the area of the rectangle. A method getPerimeter() that returns the perimeter of the rectangle. A method contains(double x, double y) that returns true if the specified point (x, y) is inside this rectangle (see Figure 10.24a ). A method contains(MyRectangle2D r) that returns true if the specified rectangle is inside this rectangle (see Figure 10.24b ). A method overlaps(MyRectangle2D r) that returns true if the specified rectangle overlaps with this…arrow_forward(The Rectangle class) Following the example of the Circle class in Section 8.2,design a class named Rectangle to represent a rectangle. The class contains:■ Two double data fields named width and height that specify the width andheight of the rectangle. The default values are 1 for both width and height.■ A no-arg constructor that creates a default rectangle.■ A constructor that creates a rectangle with the specified width and height.■ A method named getArea() that returns the area of this rectangle.■ A method named getPerimeter() that returns the perimeter.Draw the UML diagram for the class and then implement the class. Write a testprogram that creates two Rectangle objects—one with width 4 and height 40and the other with width 3.5 and height 35.9. Display the width, height, area,and perimeter of each rectangle in this order.arrow_forward
- (The Rectangle class) Following the example of the Circle class in Section 8.2,design a class named Rectangle to represent a rectangle. The class contains:■ Two double data fields named width and height that specify the width andheight of the rectangle. The default values are 1 for both width and height.■ A no-arg constructor that creates a default rectangle.■ A constructor that creates a rectangle with the specified width and height.■ A method named getArea() that returns the area of this rectangle.■ A method named getPerimeter() that returns the perimeter.Draw the UML diagram for the class and then implement the class. Write a testprogram that creates two Rectangle objects—one with width 4 and height 40and the other with width 3.5 and height 35.9. Display the width, height, area,and perimeter of each rectangle in this order.arrow_forward(Triangle class) Design a new Triangle class that extends the abstract GeometricObject class. Draw the UML diagram for the classes Triangle and GeometricObject and then implement the Triangle class. Write a test program that prompts the user to enter three sides of the triangle, a colour, and a Boolean value to indicate whether the triangle is filled. The program should create a Triangle object with these sides and set the colour and filled properties using the input. The program should display the area, perimeter, colour, and true or false to indicate whether it is filled or not.arrow_forward(Please do not give solution in image format thanku) Using Java, Integer variables totalBudget and productCost are read from input. A product costs productCost to make, and a budget is given by totalBudget. Assign remainingBudget with the remaining budget after making as many products as possible.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