Define the Circle2D class that contains:
Q: QUESTION 1 Write a class Complex for complex number system. The class should have 2 fields for real…
A: public class Complexnumber { private double real, imaginary; public Complex(double real,…
Q: Write a Student class to get the desired output as shown below. 1. Create a Student class and a…
A: As the programming language is not mentioned as per our policy i am solving using the python…
Q: Create a class MyTime which has the datamembers as follows: 1. hour: integer (1 to 12) 2. minute:…
A: #include <iostream>using namespace std; class MyTime{ private: int hour; int…
Q: 1. Write a class "Ball" which extends the class disk. It has deltax and deltay attributes. 2. Write…
A: Code in Java Language : - class disk { } class Ball extends disk { private int deltaX, deltaY;…
Q: Create an Object class and a test class to accomplish the following: Write a convertToMetric class…
A: Given, Requirements: Constructor - that accepts a length in feet (as a double) and stores it in…
Q: Design a class named MyPoint to represent a point withx- and y-coordinates. The class contains:■■…
A: UML Diagram:
Q: D Create a class Sum with the following fields, constructors and methods: Fields: create two…
A: As per the requirement program is developed. Note: In the question programming language is not…
Q: Create a class BeautyProduct with name, color, brand. Provide Constructors, getters, setters and…
A: The question asks about constructing a super class of BeautyProduct and then two child classes for…
Q: Add the following new constructor in the BMI class:/** Construct a BMI with the specified name, age,…
A: Program code: File name: BMICalculation.java //import the required packages import…
Q: Define a Rectangle class that also inherits from Quadrilateral, with the following methods:…
A: Step-1: Start Step-2: Create a class Quadrilateral Step-2.1: Create constructor for variable length…
Q: Write a class Email that contain the following fields, which other classes may not access:
A: Java program: class Email { //instance fields private String to; private String from;…
Q: Implement a class called BankAccount that is used to keep track of a bank account. This class will…
A: In the solution of given problem, we define the class BankAccount, with two private members id (int)…
Q: 1. Write a class "Ball" which extends the class disk. It has deltax and deltay attributes. 2. Write…
A: I have provided the answer based on Java Programming. Detailed comments are included for a better…
Q: Write down a class Time having fields (hrs, mins, secs), containing no argument constructor, three…
A: GIVEN: Write down a class Time having fields (hrs, mins, secs), containing no-argument constructor,…
Q: Create a class BeautyProduct with name, color, brand. Provide Constructors, getters, setters and…
A: Create three classes : BeautyProduct , Lipstick and Foundation. Then create main function which…
Q: 2019 AP® COMPUTER SCIENCE A FREE-RESPONSE QUESTIONS 2. This question involves the implementation of…
A: Note: As you have not mentioned any programming language, the program is written in JAVA language.…
Q: Implement the Critter class. Each critter C has attributes species, size, and age. • The constructor…
A: QUESTION:
Q: Define and implement a class named animal that has the following constructor and attributes:…
A: Solution: Given, Define and implement a class named animal that has the following constructor…
Q: 4. Define the Circle2D class that contains: > Two double data fields named x and y that specify the…
A: Program:…
Q: Define the Circle2D class that contains: Two double data fields named x and y that specify the…
A: public class Circle2D { //Declare the necessary variables. private double X, Y; private…
Q: Create a class Employee that has a field for storing the complete name of the employee (first and…
A: Create a class Employee that has a field for storing the complete name of the employee (firstand…
Q: 1. Implement the class bill: a. Write the constructor that takes as parameters all data fields…
A: the code is an given below : public class Bill { // private mmeners private String…
Q: Write a Student class to get the desired output as shown below. 1. Create a Student class and a…
A: Actually, python is a easiest programming language. It is a dynamically typed programming language.
Q: Extend the ItemToPurchase class to contain a new attribute. item_description (string) - Set to…
A: Below is the required python program: - Program: - #Define the class ItemToPurchase class…
Q: 2. Consider a class Time that represents a time of day. It has attributes for the hour and minute.…
A: Note: I am using python as the programming language is not mentioned. The program given below is…
Q: Create a class Rectangle with attributes length and width with are variables, each of which…
A: PROGRAM: Rectangle.java: //Header file import java.text.DecimalFormat; //Defining the class…
Q: Create a class called Box with a variable: width of type double. Inside the class define a…
A: The program for the above mentioned question is given below in step 2.
Q: 2. Implement the class Toy. The constructor takes as parameters the receiver's name, the price, the…
A: class Gift{ private String receiver; private double price; public Gift(r,p){…
Q: Write a Rectangle class that has the following fields: Length (L): a double Width (W): a double The…
A: Since the language was not mentioned , the answer is provided in C++ language. Code: #include…
Q: Create a class Animal with a constructor that takes no parameters and has an instance variable:…
A: public class Animal {//Instance variableprivate int energy;//Energy is 1 when it is bornpublic…
Q: Write a Circle class that has the following field: radius: a double The class should have the…
A: import java.util.Scanner; public class Demo { public static void main(String[] args) { Scanner…
Q: Need help on this. Must be in java. Make the code unique and no plagerism. Implement a Java class…
A: A class named Square is implemented which has one of its coordinates and the side of it as the…
Q: Create a class AccessPoint with the following attributes: x - a double representing the x…
A:
Q: Write a Rectangle class that has the following fields: Length (L): a double Width (W): a double The…
A: * Writting program in c++ as no programming language in mentioned in the question. #include…
Q: A. Create a BankAccount class. We want to be able to create a new bank account, make deposits and…
A: For creating the Bank account project we need two classes inorder to represent the Bank account…
Q: Write a Rectangle class. Its constructor should accept length and width as a parameter. It should…
A: Answer has been explained below:-
Q: Write a convertToMetric class that has the following field: standard - holds a double, standard…
A: Actually, the code has given below:
Q: 02) Design and implement a class named Triangle that extends GeometricObject. Theclass contains: •…
A: Algorithm: Start Create an abstract class named GeometricObject with data members color and filled…
Q: Write a class Point for 2D Cartesian co-ordinates. The class should have 2 fields: abscissa(x) anc…
A: As mentioned in the question im writing a class point for 2D Cartesian co-ordinates
Q: Write a class called Dog that contains instance data that represents the dog's (string literal) name…
A: main.java (code) public class Main { public static void main(String[] args) { // Creating…
Q: Create a class Divide with the following fields, constructors and methods: Fields: create two…
A: Please see that the code has been written in step 2 and the corresponding output has been shared in…
Q: 10.4 (THE MYPOINT CLASS) Design a class named My Point to represent a point with x- and…
A: The question is to write the JAVA code for the given problem.
Q: Write a program which controls a metro train and that keeps track of stations and who gets on and…
A: Actually, Python is the easiest programming language. It is a dynamically typed programming…
Q: Create a class Course, which has one field: String courseName Create the constructor, accessor,…
A: public class Course{ private String courseName; //Constructor Course() {…
Q: Write a shoe class with the following attributes: color (e.g., "blue", "green", "orange")…
A: Step 1:- Given:- 1.Create a class Clothing and its attributes are color,displayName, and price…
Q: Extend the ItemToPurchase class per the following specifications: Private fields string…
A: import java.util.*;import java.lang.*;import java.io.*; class Item{ private String itemName;…
Q: Write a convertToMetric class that has the following field: standard - holds a double, standard…
A: import java.util.*;class convertToMetric { double standard; public convertToMetric(double standard)…
Q: Write a java program to create a class Rectangle. The class has attributes Length and Width. It…
A: Below is the java program with comments and output snapshots.
Q: Create a class Fraction with two integer final fields: numeratorand denominator. Its constructor…
A: Introduction of the Program: The Java program makes a Fraction class and this class has two member…
Define the Circle2D class that contains:
- Two double data fields named x and y that specify the center of the circle with get
- A data field radius with a get
- A no-arg constructor that creates a default circle with (0, 0) for (x, y) and 1 for radius.
- A constructor that creates a circle with the specified x, y, and radius.
- A method getArea() that returns the area of the circle.
- A method getPerimeter() that returns the perimeter of the circle.
- A method contains(double x, double y) that returns true if the specified point (x, y) is inside this circle. See Figure 10.14(a).
- A method contains(Circle2D circle) that returns true if the specified circle is inside this circle. See Figure 10.14(b).
- A method overlaps(Circle2D circle) that returns true if the specified circle overlaps with this circle. See the figure below.
(a) (b) (c)
Figure 10.14
(a) A point is inside the circle. (b) A circle is inside another circle. (c) A circle overlaps another circle.
Draw the UML diagram for the class. Implement the class. Write a test program that creates a Circle2D object c1 (new Circle2D(2, 2, 5.5)), displays its area and perimeter, and displays the result of c1.contains(3, 3), c1.contains(new Circle2D(4, 5, 10.5)), and c1.overlaps(new Circle2D(3, 5, 2.3)).
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- In Java, Create a class Rectangle with double attributes length and width. The default constructor should set these attributes to 1. Provide methods that calculate the rectangle's perimeter and area, as well as accessors and mutators for both data fields. The mutator methods for length and width should verify that the number being passed in is larger than 0.0 and less than 20.0 -- if it doesn't fit those criteria, the value of the field should not be changed.Write a Driver class in the same file to test your Rectangle class. It should prompt the user to enter a length and width of a rectangle, and then print out the area and perimeter of the rectangle. (Use the mutators to set the length and width of the rectangle, not the constructor.)Define the Circle2D class that contains: Two double data fields named x and y that specify the center of the circle with get methods. A data field radius with a get method. A no-arg constructor that creates a default circle with (0, 0) for (x, y) and 1 for radius. A constructor that creates a circle with the specified x, y, and radius. A method getArea() that returns the area of the circle. A method getPerimeter() that returns the perimeter of the circle. A method contains(double x, double y) that returns true if the specified point (x, y) is inside this circle. See Figure 10.14(a). A method contains(Circle2D circle) that returns true if the specified circle is inside this circle. See Figure 10.14(b). A method overlaps(Circle2D circle) that returns true if the specified circle overlaps with this circle. See the figure below. Figure (a) A point is inside the circle. (b) A circle is inside another circle. (c) A circle overlaps another circle. Draw the UML diagram for the class.…1: create a class Pentagon, which implements the RegularPolygon interface. It should have a double field called length, as well as a constructor that initializes this length field to a given value. 2: In the main() method of Pentagon class, add the following code: RegularPolygon sq = new Square(10); RegularPolygon penta = new Pentagon(20); Write code to get the perimeter for sq and penta. 3: In the main() method defined in Q2, add this line of code: sq.getArea(); Will this code pass through compiler? What is the reason? The Java feature in Q1 which create a new version of predefined method getPerimeter() is called Polymorphism Override Overload Inheritance
- Write a class 'Cylinder' that has two fields: height and radius. The class should have only one parameterized constructor function to initialize these fields. The class should also have a method 'getVolume()' to calculate the volume of this cylinder. Now, create any 2 objects of this class with arbitrary values and show their volumes.Create an Object class and a test class to accomplish the following: Write a convertToMetric class that has the following field: standard - holds a double, standard length value in feet. The class should have the following methods: Constructor - that accepts a length in feet (as a double) and stores it in the standard field. setStandard - accepts a standard length in feet and stores it in standard. getStandard - returns the value of the standard field, as a length in feet, no conversion required. getMeters - returns the value of the standard field converted to meters. getCentimeters - returns the value of the standard field converted to centimeters A second class will be created and used to test the new object class. This, executable class, is to instantiate an object of 'convertToMetric' type. Then it will allow the user to use keyboard input to input a value for standard. That value will then be converted to meters and centimeters, and displayed. Make sure that your output (or…Create an Object class and a test class to accomplish the following: Write a convertToMetric class that has the following field: standard - holds a double, standard length value in feet. The class should have the following methods: Constructor - that accepts a length in feet (as a double) and stores it in the standard field. setStandard - accepts a standard length in feet and stores it in standard. getStandard - returns the value of the standard field, as a length in feet, no conversion required. getMeters - returns the value of the standard field converted to meters. getCentimeters - returns the value of the standard field converted to centimeters A second class will be created and used to test the new object class. This, executable class, is to instantiate an object of 'convertToMetric' type. Then it will allow the user to use keyboard input to input a value for standard. That value will then be converted to meters and centimeters, and displayed. Make sure that your output (or…
- D Create a class Sum with the following fields, constructors and methods:Fields: create two integer fields Constructors:- a no-argument constructor- a constructor with two parameters Methods:- write a getter to return the sum of fields- Create 4 overloaded calculate methods 1. method receives two integer parameters and returns the sum 2. method receives four integer parameters and returns the sum 3. method receives two double parameters and returns the sum 4. method receives two String parameters and returns the sum Create a demo class to test the two constructors, all the methods and display the returned values. You can hard code the parameters values. Make sure the four methods created are toverloaded i.e. same method name for all four.Create a class Divide with the following fields, constructors and methods:Fields: create two double fields called numerator and denominator Constructors:- a no-argument constructor- a constructor with two parameters Methods:- write a getter to return the result of numerator divided by denominator- Create 4 overloaded calculate methods. Note: Division would be numerator divided by denominator 1. method receives two double parameters and returns the result of the division as double 2. method receives two integer parameters and returns the result of the division as double 3. method receives one integer parameter and another as double parameter and returns the result of the division as int 4. method receives two String parameters and returns the result of the division as int Create a demo class to test the two constructors, all the methods and display the returned values. You can hard code the parameters values when calling the constructor and the methods.Is there a different way of doing this problem? Question: Create a class AccessPoint with the following attributes: x - a double representing the x coordinate y - a double representing the y coordinate range - an integer representing the coverage radius status - On or Off Add constructors. The default constructor should create an access point object at position (0.0, 0.0), coverage radius 0, and Off. Add accessor and mutator functions: getX, getY, getRange, getStatus, setX, setY, setRange and setStatus. Also, add a set function that sets the location coordinates and the range. Add the following member functions: move and coverageArea. Add a function overlap that checks if two access points overlap their coverage and returns true if they overlap. Add a function signalStrength that returns the wireless signal strength as a percentage. The signal strength decreases as one moves away from the access point location. Test your class by writing a main function that creates five access…
- For the 'The Chicken class' on the app intelliJ in java. The Chicken class must:• Define three fields called exactly name, pricePerKilo and inStock. The name field must be of type String, the pricePerKilo must be of type int (representing the cost per kilo in pence) and the inStock field must be of type boolean.• Initialise the three fields via a constructor that takes exactly two parameters. The first parameter must be of type String and the second parameter must be of type int. The first parameter must initialise the name field and the second must initialise the pricePerKilo field. The constructor must set the inStock field to true for all Chicken objects. There must be no parameter to the constructor for the inStock field.• Define getters for all three fields using the standard getter naming convention. In particular, note that the getter for the inStock field must be called getInStock rather than isInStock.• Define setters for the pricePerKilo and inStock fields using the standard…Create a class Course, which has one field: String courseName Create the constructor, accessor, and mutator for the class. Then, in the main method of this class, create an instance of the class with the name "CST1201". Write an equivalent while statement to replace the following for statement for (int i=2; i<100; i=i+2) { System.out.println(i); }I tried to get this answered before but I couldn't get the code to work fully from what he gave me. " //Definition of class rectangle public class Rectangle { //Declare required variables private double w; private double h; //No-argument constructor public Rectangle() { //Assign "w" to "1" w = 1; //Assign "h" to "1" h = 1; } //Parameterized constructor public Rectangle(double wid, double ht) { //Assign "wid" to "w" this.w = wid; //Assign "ht" to "w" this.h = ht; } //Method definition for width public double getWidth() { //Return width return w; } //Method definition for height public double getHeight() { //Return height return h; } //Method definition for perimeter public double getPerimeter() { //Return the perimeter return 2.0*(w + h); } //Method definition for area public double getArea() { //Return the area return w*h; } }//Definition of test class public class Test { //Definition of main class public static void main(String[] args) { //Create an object for rectangle class…