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
- Create a RightTriangle class given the following design: RightTriangle variables: base, height methods: 2 constructors, 1 that set default values and another that accepts to parameters. setBase - changes the base. Requires one parameter for base. setHeight - changes the height. Requires one parameter for height. getBase - returns the triangle base. getHeight - returns the triangle height. area - returns the area of the triangle (1/2bh) given the current base and heightRectangle Object Monitoring Create a Rectangle class that can compute the total area of all the created rectangle objects using static fields (variables). Remember that a Rectangle has two attributes: Length and Width. Implement the class by creating a computer program that will ask the user about three rectangle dimensions. The program should be able to display the total area of the three rectangle objects. For this exercise, you are required to apply all OOP concepts that you learned in class. Sample output: Enter Length R1: 1 Enter Width R1: 1 Enter Length R2: 2 Enter Width R2: 2 Enter Length R3: 3 Enter Width R3: 3 The total area of the rectangles is 14.00 Note: All characters in boldface are user inputs.Design a class named Rectangle to represent a rectangle. The class must have the following: • double data fields named width and height. The default values are 1 for both width and height A no-argument constructor that creates a default bag. A constructor that creates a rectangle with the specified width and height A getParameter() method to return the perimeter. • A getArear() method to return the area of the Rectangle. Create two Rectangle objects. One with width 4.0 and height 10.0. The other object has width 6.3 and height 10.5.
- package assignment; public class Circle2D2 { //data fields specifying the center of the circle private double x, y; //data field radius private double radius; //default circle with (0, 0) for (x, y) and 1 for radius Circle2D2() { this(0, 0, 1); } //circle with the specified x, y, and radius Circle2D2(double x, double y, double radius) { this.x = x; this.y = y; this.radius = radius; } //return x public double getX() { return x; } //return y public double getY() { return y; } //return radius public double getRadius() { return radius; } //return the area of the circle public double getArea() { return Math.PI * Math.pow(radius, 2); } //return the perimeter of the circle public double getPerimeter() { return 2 * Math.PI * radius; } //return true if the specified point (x, y) is inside this circle public boolean contains(double x, double y) { return Math.sqrt(Math.pow(x - this.x, 2) + Math.pow(y - this.y, 2)) < radius; } //return true if…Temp Class - Create Temp class whos job is to hold a temp in degrees F and gives methods to get the temp in F, Celsius, and Kelvin. The class should follow the instance variable (field): ftemp (double type that holds F temp)Follow these methods with the class.. Constructor --Will accept Fahrenheit temperature as a double to store it in the ftemp field. setFahrenheit - The setFahrenheit method accepts a Ftemperature as a doubleto stores it in the ftemp field. getFahrenheit - Returns the value of the ftemp field, as a Fahrenheit temperature (no conversion required). getCelsius - Returns the value of the ftemp field converted to Celsius. [C e l s i u s = ( 5.0 / 9.0 ) × ( F a h r e n h e i t − 32 )] getKelvin - Returns the value of the ftemp field converted to Kelvin. [K e l v i n = ( ( 5.0 / 9.0 ) × ( F a h r e n h e i t − 32 ) ) + 273] Exemplify the temp class by writing a (test) program that is separate and promotes users for an F Fahrenheit temp. The program must create an…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.…
- Write a Circle class that has the following field: • radius: a double The class should have the following methods: no-arg constructor constructor: accepts the radius of the circle as an argument. setRadius: A mutator method for the radius field. getRadius: An accessor method for the radius field. getArea: returns the area of the circle. getDiameter: returns the diameter of the circle. getCircumference: returns the circumference of the circle Write a program that demonstrates the use of the Circle class by asking the user for the circle's radius, creating a Circle object, and then reporting the circle's area, diameter, and circumference.In Javascript, Pet Class: Design a class named Pet, which should have the following fields and methods: name: The name of a pet type: The type of animal the pet is ("Dog", "Cat", "Lizard", etc.) age: The age of the pet. setName: The setter for the name field. getName: The getter for the name field. setType: The setter for the type field. getType: The getter for the type field. setAge: The setter for the age field. getAge: The getter for the age field. Once you have designed the class, create an instance of the class and use the setter and getter methods to store data in the object and display the data.Design a class named StopWatch. The class contains:■ The private data fields startTime and endTime with get methods.■ A constructor that initializes startTime with the current time.■ A method named start() that resets the startTime to the current time.■ A method named stop() that sets the endTime to the current time.■ A method named getElapsedTime() that returns the elapsed time for thestop watch in milliseconds.Draw the UML diagram for the class, and then implement the class. Write a test program that measures the execution time of adding numbers from 1 to 1,000,000.
- 1. Part 1: A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design the class Point that can store and process a point in the x-y plane. Your class should contains the following methods. Default constructor without parameters that initializes the private data member to the suitable values Constructor with parameters sets the values of the instance variables to the values of the parameter. Accessor methods that return the values of the x-axis and y-axis. setPoint method which set the values of x-axis and y-axis makeCopy method that make a copy of a received object of type Point. getCopy method that returns a copy of the current object toString method that returns the object string isEqual that returns true if the current object is equal to the received object of type point distance, which receives two objects of type Point and returns the distanceDesign and implement a class called Car that contains instance data that represents the company, price, model, and year of the car. Define the Car constructor to initialize these values. Include getter and setter methods for all instance data, and a toString method that returns a one-line description of the car. Create a driver class called CarTest, whose main method instantiates array of Car objects and write the following methods: 1) Method “printInfo” that receives an array of cars and returns all information about all cars. 2) A Method called getTopByCompany that receives an array of Cars and then returns an array of cars containing the cars that have the highest price compared with cars from the same company.Design a LandTract class that has two fields (i.e. instance variables): one for the tract’s length(a double), and one for the width (a double). The class should have: a constructor that accepts arguments for the two fields a method that returns the tract’s area(i.e. length * width) an equals method that accepts a LandTract object as an argument. If the argument object holds the same data (i.e. length and width) as the calling object, this method should return true. Otherwise, it should return false. a toString method (that returns a String representation of the tract’s length, width, and area). Demonstrate the class in a program by creating an array of three LandTract objects initialized with user input. Then, print the info of the LandTract objects stored in the array by invoking the toString method (implicitly or explicity). Also, use the equals method to compare at least two LandTract objects and print wether they are of equal size or not. Sample Output:…