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 13, Problem 13.10PE
Program Plan Intro
Rectangle.java
Program Plan:
- Include a class name named “Exercise_13_10”.
- Declare the main() method.
- Create three rectangle objects and assign values to them using the Rectangle class.
- Display the area of each circle object referencing Rectangle class.
- Display if Rectangle1 is equal to Rectangle 2 or not by referencing Rectangle class.
- Close the main() method.
- Close the class.
- Include an abstract class “GeometricObject”.
- Declare all the data types of the variables.
- Construct a default geometric object.
- Construct a geometric object with color and filled value.
- Assign color and fill to the object.
- Set a new color.
- Define an isFilled method returns filled and since filled is Boolean; the get method is named isFilled.
- Set a new filled and getDateCreated method.
- Override toString function to return output.
- Define Abstract method getArea.
- Define Abstract method getPerimeter.
- Close class.
- Include a class “Rectangle” that extends the class GeometricObject and implements Comparable.
- Declare width and height of rectangle.
- Create a Rectangle constructor.
- Assign values to height and width.
- Assign rectangle values to all attributes.
- Create a function to return width.
- Create a function to return radius.
- Create a function to set a new width.
- Create a function to return height.
- Create a function to set a new height.
- Create an override function to return area.
- Create an override function to return Perimeter.
- Create an override function that returns true if objects area is the same.
- Create an override function to implement compareTo method.
- Close class.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Triangle class) Design a new Triangle class that extends the abstract
Geometricobject class. Draw the UML diagram for the classes Triangle and
Geometricobject then implement the Triangle class. Write a test program
that prompts the user to enter three sides of the triangle, a color, and a Boolean
value to indicate whether the triangle is filed. The program should create a Tri-
angle object with the se sides, and set the color and filled properties using the
input. The program should display the area, perimeter, color, and true or false to
indicate whether it is filled or not.
(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.
(Java)
Question 5
Explain the answer step-by-step and include verbal explanation. Thank you!
Write an interface as follows:
The interface is named ServiceReminder
It has one method named timeForService that has no parameters and returns a boolean variable.
Now, update the below class so that is inherits from ServiceReminder
Note that the next service date should be 90 days from the last service
public abstract class Car { private double gasGauge; private double currMileage; private String color; private String make; private String model; private int daysLastService; public Car(String color, String make, String model, int daysLastService) { this.color = color; this.make = make; this.model = model; gasGauge = 0.0; currMileage = 0.0; this.daysLastService = daysLastService; } @Override public String toString() { return "Make: " + make + "\nModel: " + model + "\nColor: " + color…
Chapter 13 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 13.2 - Prob. 13.2.1CPCh. 13.2 - The getArea() and getPerimeter() methods may be...Ch. 13.2 - True or false? a.An abstract class can be used...Ch. 13.3 - Prob. 13.3.1CPCh. 13.3 - Prob. 13.3.2CPCh. 13.3 - Prob. 13.3.3CPCh. 13.3 - What is wrong in the following code? (Note the...Ch. 13.3 - What is wrong in the following code? public class...Ch. 13.4 - Can you create a Calendar object using the...Ch. 13.4 - Prob. 13.4.2CP
Ch. 13.4 - How do you create a Calendar object for the...Ch. 13.4 - For a Calendar object c, how do you get its year,...Ch. 13.5 - Prob. 13.5.1CPCh. 13.5 - Prob. 13.5.2CPCh. 13.5 - Prob. 13.5.3CPCh. 13.5 - Prob. 13.5.4CPCh. 13.6 - Prob. 13.6.1CPCh. 13.6 - Prob. 13.6.2CPCh. 13.6 - Can the following code be compiled? Why? Integer...Ch. 13.6 - Prob. 13.6.4CPCh. 13.6 - What is wrong in the following code? public class...Ch. 13.6 - Prob. 13.6.6CPCh. 13.6 - Listing 13.5 has an error. If you add list.add...Ch. 13.7 - Can a class invoke the super.clone() when...Ch. 13.7 - Prob. 13.7.2CPCh. 13.7 - Show the output of the following code:...Ch. 13.7 - Prob. 13.7.4CPCh. 13.7 - What is wrong in the following code? public class...Ch. 13.7 - Show the output of the following code: public...Ch. 13.8 - Prob. 13.8.1CPCh. 13.8 - Prob. 13.8.2CPCh. 13.8 - Prob. 13.8.3CPCh. 13.9 - Show the output of the following code: Rational r1...Ch. 13.9 - Prob. 13.9.2CPCh. 13.9 - Prob. 13.9.3CPCh. 13.9 - Simplify the code in lines 8285 in Listing 13.13...Ch. 13.9 - Prob. 13.9.5CPCh. 13.9 - The preceding question shows a bug in the toString...Ch. 13.10 - Describe class-design guidelines.Ch. 13 - (Triangle class) Design a new Triangle class that...Ch. 13 - (Shuffle ArrayList) Write the following method...Ch. 13 - (Sort ArrayList) Write the following method that...Ch. 13 - (Display calendars) Rewrite the PrintCalendar...Ch. 13 - (Enable GeometricObject comparable) Modify the...Ch. 13 - Prob. 13.6PECh. 13 - (The Colorable interface) Design an interface...Ch. 13 - (Revise the MyStack class) Rewrite the MyStack...Ch. 13 - Prob. 13.9PECh. 13 - Prob. 13.10PECh. 13 - (The Octagon class) Write a class named Octagon...Ch. 13 - Prob. 13.12PECh. 13 - Prob. 13.13PECh. 13 - (Demonstrate the benefits of encapsulation)...Ch. 13 - Prob. 13.15PECh. 13 - (Math: The Complex class) A complex number is a...Ch. 13 - (Use the Rational class) Write a program that...Ch. 13 - (Convert decimals to fractious) Write a program...Ch. 13 - (Algebra: solve quadratic equations) Rewrite...Ch. 13 - (Algebra: vertex form equations) The equation of a...
Knowledge Booster
Similar questions
- (Implement MyLinkedList) The implementations of the methods contains(E e), get(int index), indexOf(E e), lastIndexOf(E e), and set(int index, E e) are omitted in the MyLinkedList class. Implement these methods. Define a new class named MyLinkedListExtra that extends MyLinkedListto override these methods. Test your new MyList class using the code at import java.util.*; public class Exercise24_02 { public static void main(String[] args) { new Exercise24_02(); } public Exercise24_02() { String[] names = {"Tom", "Susan", "Kim", "George", "Peter", "Jean", "George", "Jane", "Denise", "Jenny", "Susan", "Kathy", "Jane"}; MyList<String> list = new MyLinkedListExtra<>(names); System.out.println(list); Scanner input = new Scanner(System.in); System.out.print("Enter a name: "); String name = input.next(); System.out.print("Enter an index: "); int index = input.nextInt(); System.out.println(name + " is in the list? " +…arrow_forward(The MyPoint class) Design a class named MyPoint to represent a point with x- and y-coordinates. The class contains: 1 The data fields x and y that represent the coordinates with getter methods. 1 A no-arg constructor that creates a point (0, 0). I A constructor that constructs a point with specified coordinates. I A method named distance that returns the distance from this point to a specified point of the MyPoint type. I A method named distance that returns the distance from this point to another point with specified x- and y-coordinates. Draw the UML diagram for the class and then implement the class. Write a test program that creates the two points (0, 0) and (10, 30.5) and displays the distance between them.arrow_forward(Car Class) Create a class called Car that includes three instance variables-a model (type String), a year (type String), and a price (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the price is not positive, do not set its value. Write a test application named CarApplication that demonstrates class Car's ca- pabilities. Create two Car objects and display each object's price. Then apply a 5% discount on the price of the first car and a 7% discount on the price of the second. Display each Car's price again. 3.13arrow_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(The ComparableSquare class) Define a class named ComparableSquare thatextends Square and implements Comparable. Implement the compareTo methodto compare the Squares on the basis of area. Write a test class to find the larger oftwo instances of ComparableSquareobjects.arrow_forward
- (2e flaiks) An object of class Student (download the code from Blackboard) stores the studentName, the studentNumber and the major of a student. The class has the following methods: FinalExamProblem-2 • computeTuitionFees, which returns the fees paid by a student each term, • degreeToBeGranted, which returns the degree that will be grabnted to the student on successful graduation, and changeMajor, which changes the major the student is pursuing. Methods computeTuitionFees and degreeToBeGranted use complex conditional statements. To remove bad smells from the code, I have refactored the solution and provide a sample class diagram below. Your task is to implement the following class diagram using Java so that the purpose of the problem remains the same and still gives you the same output. Use the same FinalExamProblemTwoMain class. You are not allowed to make any changes in the FinalExamProblemTwoMain class. UNRE ERED UNREC TERED UNREGISTERED UNREGISTERED EGISTERED UNREGISTERED Student…arrow_forward(JAVA)Write an abstract class for Shape. The intended subclasses are Polygon, Circle, Triangle, and Rectangle. All of these will have a name, an area, and a perimeter. (Consider which methods might be abstract.) Add a toString method that will return the information about the Shape, for example: Triangle, Area: 7.5, Perimeter: 12.0arrow_forward(USE JAVA) Create a Pseudocode for the main methods of the situation on the picture below.arrow_forward
- (WRITE JAVA CODE AND SEND SCREENSHOTS) You need to develop a system in Java for a Juice company. Create a class Juice with data member’s sugar, flavour, size, amount of water, and price. Write required Constructors (no argument and parameterize) for this class. Write a member method showJuice() to display the contents of a juice object though you may have to write some more methods as per need. In main() method you need to create different juices with the following specifications: 1) Sugar = 5g, flavor = mango, size = ½ (half liter), water = ½ liters, price = $1 2) Sugar = 2g, flavor = orange, size = ½ (half liter), water = ½ liters, price = $2 3) Sugar = 3g, flavor = graps, size = ½ (half liter), water = ½ liters, price = $3 You also need to create 1 litter juices for the company by adding objects of two half litter juices. While adding two half litter flavours to make a 1 litter juice, make sure you can only add same flavour juices. If two…arrow_forward(Java) Question 6 Explain the answer step-by-step and include verbal explanation. Thank you! Given the below Tesla class, update the class to inherit from the Comparable interface and also write a compareTo method that orders two Tesla objects according to 1. model, 2. range, and 3. color: public class Tesla { private String model; private int range; private String color; public Tesla(String model, int range, String color) { this.model = model; this.range = range; this.color = color; } @Override public boolean equals(Object o) { if (this == o) return true; } else if (!(o instanceof Tesla)) { return false; } else { Tesla t = (Tesla) o; return model.equals(t.model) && range == t.range && color.equals(t.color); } }}arrow_forward(PLEASE ANSWER IN C++) I need help with a practice problem. Im goIng to start out the question then post the rest ofthe question in an image : Create 2 classes, 1 called "Dog" and 1 called Lab13B.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