4. LandTract Class Make a LandTract class that has two fields: one for the tract's length and one for the width. The class should have a method that returns the tract's area, as well as an equals method and a toString method. Demonstrate the class in a program that asks the user to enter sh dimensions for two tracts of land. The program should display the area of each tract of land and indicate whether the tracts are of equal size.
Q: 2. Create a class and an object as the following diagrams carl: Car Car speed= 240 - speed: int…
A: PROGRAM CODE: // import the required librariesimport java.util.*;class Car{ // declare the…
Q: Complete the Car class by creating an attribute purchase_price (type int) and the method…
A: Find Your Code Below
Q: (Algebra: quadratic equations) Design a class named QuadraticEquation for a quadratic equation ax² +…
A: UML Diagram of QuadraticEquation:
Q: Design a LandTract class that has two fields (i.e. instance variables): one for the tract’s length(a…
A: public class LandTract { double length; double width; public LandTract(double length, double width)…
Q: gn and i mp. the đày ôf the week in a program. The class dayType should store the day, such as Sun…
A: #ifndef DAYTYPE_H#define DAYTYPE_H#include<string>using std::string; class dayType{ public:…
Q: instanc variables: Full name (String), age(int), address(String), years of constructor that sets all…
A: here in this Program we have to defined class Employee which consist on five pieces of information…
Q: Preliminaries • Write a Point class with two properties: r, y. Write required constructor, get &…
A: NOTE: As per the policy we can answer only one question at a time, kindly repost the other part to…
Q: Design a class named MyInteger. The class contains: An int data field named value(int) Methods…
A: A number is said to be even if it leaves remainder 0 when divide by 2 A number is said to be odd if…
Q: A square is an equilateral and equiangular polygon by default. Implement these properties of a…
A: import java.util.Scanner; public class AreaAndPerimeterOfSquare { public static void…
Q: Assignment 4 - Car Maintenance This assignment will assess your understanding of void and value…
A: Actually, the code given below:
Q: Part (2) Write a Java application that asks the user to enter the length and width of a room and the…
A: The steps to create the program are listed below. Create a class RoomCarpet to store the length and…
Q: Define and implement class Employee. This class should contain the following fields: first name,…
A: For designing the java program with the given specifications, do the following: Create class…
Q: Java. Modify a dealership's Automobile class so it includes fields for an id (ID number), make,…
A: The Code is given below:
Q: C++ Part A. // declare a class called Time with // 1) two int data members called hour and min //…
A: The complete answer is given below .
Q: Q No#1 (Area Class) Write a program to print the area of a rectangle by creating a class named…
A: Declare two variables in the main() method. Read the values from the user using the Scanner class…
Q: Slide Type Slide · Exercise # 2: Implement a class Portfolio. This class has two objects, checking…
A: Required:
Q: reate a class called Point which will have 2 co-ordinate value x & y and will be able to calculate…
A: Given question has asked to create a class called point have 2 co-ordinate value x & y and will…
Q: Q1: Class Create a class that can represent times. The class will have member variables hours and…
A: Note: Answering in python and first question as per guidelines. Class Name : times Class Variables…
Q: Design a class name Fruit Basket offering multiple baskets to the customer. purchaseBasket(int…
A: Solution: Approach: Create a class named FruitBasket Declare the default price of fruits as final…
Q: if anything missing from the question like how many time we have to call function add it by yourself…
A: Actually, program is an executable software that runs on a computer.
Q: Write the printTime method for the Time class. It takes no arguments and returns nothing. This…
A: #include<bits/stdc++.h>using namespace std;//It is 24 hour time format since no AM,PM is…
Q: You are required to design an Movie class which has following attributes String name;…
A: The code is
Q: #this is a python program #topic: OOP Design a class called Pokemon using a parameterized…
A: Find Your Code Below
Q: Create a class called Point which will have 2 co-ordinate value x & y and will be able to calculate…
A: Write the C++ code as follows: Define the class Point with two data members representing coordinate…
Q: Preliminaries • Write a Point class with two properties: 1, y. Write required constructor, get &…
A: Please give positive ratings for my efforts. Thanks. PROGRAM class Point { int x,y; public…
Q: Java. Modify a dealership's Automobile class so it includes fields for an id (ID number), make,…
A: ALGORITHM:- 1. Fill all the empty functions with the correct logic as provided. 2. Test with the…
Q: (Algebra: quadratic equations) Design a class named QuadraticEquation for a quadratic equation ax² +…
A: A complete answer in Java Programming language is given below:
Q: 2. Create a class that will convert a dollar to peso, the class must accept 1 value as arguments,…
A:
Q: Create a class named RealEstate that has data members to hold the price of a house, the number of…
A: User-Defined Exception: class myException { // Declare variable to store exception message…
Q: In this exercise, you have to create a class called Point which can calculate distance between two…
A: Here I ahve copied the code from the question and defined the methods and constructor to produce the…
Q: 1. Refactor the following code for encapsulation (information hiding). (5 points) FILL IN BLANKS on…
A: public class School { private String name; private String id; public String getName() { return…
Q: You are required to design an Movie class which has following attributes String name;…
A: import java.io.*;class Movie{ // attributes private String name; private String Director;…
Q: You are required to design a movie class which has following attributes String title;…
A: Here is the java code: TestMovie.java import java.util.Scanner; public class Main { public static…
Q: Q No#1 (Area Class) Write a program to print the area of a rectangle by creating a class named…
A: A class is a user-defined data type that combines data members and methods for manipulating that…
Q: Preliminaries • Write a Point class with two properties: 1, y. Write required constructor, get &…
A: EXPLANATION: - The Point class comprises two instance variables of type double. The parameterized…
Q: Nutritional information (classes/constructors) PYTHON ONLY Complete the FoodItem class by adding a…
A: Given: Complete the FoodItem class by adding a constructor to initialize a food item. The…
Q: O Challenge task Write the code of the Constructors and Distructor for the following class 1-Write…
A: Include header files Define a class with class name constructor and data member X and Y as integers…
Q: (Physics: acceleration) Average acceleration is defined as the change of velocity divided by the…
A: Program –
Q: Part (1) Create a class named Item, that includes two private members: Type (String), and…
A: Given: Part (1) Create a class named Item, that includes two private members: Type (String), and…
Q: Equation Slope (-a / b) Is point (5, -2) on the line? 5x+ 4y - 17 - 0 -5/4--1.25 Yes, because 5(5) +…
A: Source Code: APLine.java: public class APLine { private int a; private int b;…
Q: Write a program that test methods in the class. Hint: the employee deserved retirement if he has…
A: Algorithm - Step 1 - Start code. Step 2 - input number. Step 3 - if(number is perfectly divisible by…
Q: Invoicing.java Create a class named Invoicing (no instance private data fields) that includes three…
A: Here is the detailed explanation of the program
Q: You are required to design an Movie class which has following attributes String name;…
A: In the java program, add the necessary and required libraries for the program. For example, the…
Q: Description (same for next three questions) Your job is to write an instantiable class that…
A: Answer: our guidelines is answer first three question from the first question. So I have given…
Q: • Shape (this will be the base class) o The _init_ method should take in just the identifier and…
A: Note: There is no method/function call in the given code. The code is according to the given…
Q: 1- Design a class named Fan to represent a fan. The class contains: -Three constants named SLOW,…
A: class Fan{public static final int SLOW=1,MEDIUM=2,FAST=3;int speed;boolean f_on;double radius;String…
Q: Write an application that uses an abstract Insurance class and Health and Life subclasses to display…
A: public abstract class Insurance{ protected String type; protected double cost; public…
Q: Complete the Car class by creating an attribute purchase_price (type int) and the method…
A: class Car: def __init__(self): self.model_year = 0 # TODO: Declare…
Q: Learn C++ | Sololearn X Member Initializers G Problem 18°C Cloudy X Member Initializers 144Hz…
A: answer starts from step 2
Q: Write a program that test methods in the class. • Hint: the employee deserved retirement if he has…
A: Algorithm - Step 1: - Start code. Step 2: - input number. Step 3: - if(the number is perfectly…
Java program
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images
- 7)Circle Class Write a Circle class that has the following fields: radius: a double PI:a final double initialized with the value 3.14159 The class should have the following methods: Constructor. Accepts the radius of the circles as an argument. Constructor. A no-arg constructor that sets the radius field to 0.0. setRadius. A mutator method for the radius field. getRadius.An accessor method for the radius field. area. Returns the area of the circle, which is calculated as area. Returns the area of the circles, which is calculated as area= PI * radius * radius diameter. Returns the diameter of the cirlce, which is calculated as diameter = radius * 2 circumference. Returns the circumference of the circle, which is calculated as circumference = 2 * PI * radius Write a program that demonstrates the Circle class by asking the user for the circles's radius, creating a Circle object, and then reporting the cirlce's area, diameter, and circumference.JAVA - USING CONSTRUCTORS Create a class named House that includes data fields for the number of occupants and the annual income as well as methods named setOccupants(), setIncome(), getOccupants() and getIncome() that set and return those values respectively. Additionally, create a constructor that requires no arguments and automatically sets the occupants field to 1 and income field to 0. Create an additional overloaded constructor . This constructor receives an integer argument and assigns the value to the occupants field. Create a third overloaded constructor this time, the constructor receives 2 arguments, the values of which are assigned to the occupants and income fields respectively. Create another class named I_house that instantiates the House class and see if the constructors work correctly.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:…
- 2. Car Class Write a class named car that has the following fields: ▪ yearModel. The year Model field is an int that holds the car's year model. ▪ make. The make field is a String object that holds the make of the car, such as "Ford", "Chevrolet", "Honda", etc. ▪ speed. The speed field is an int that holds the car's current speed. In addition, the class should have the following methods. ■ Constructor. The constructor should accept the car's year model and make as arguments. These values should be assigned to the object's year Model and make fields. The constructor should also assign 0 to the speed field.Circle ClassWrite a Circle class that has the following fields:• radius: a double• PI: a final double initialized with the value 3.14159The class should have the following methods:• Constructor. Accepts the radius of the circle as an argument.• Constructor. A no-arg constructor that sets the radius field to 0.0.• setRadius. A mutator method for the radius field.• getRadius. An accessor method for the radius field.• area. Returns the area of the circle, which is calculated asarea = PI * radius * radius• diameter. Returns the diameter of the circle, which is calculated asdiameter = radius * 2• circumference. Returns the circumference of the circle, which is calculated ascircumference = 2 * PI * radiusWrite a program that demonstrates 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.Build a class named car. This class is defined as follows: It has the fields: Car ID, Car model , Car make, Car color, Car year. Build a constructor that accepts the five parameters (Car ID, Car model , Car make,Car color, Car year). Override the method toString() to return the string representation of Car ID, Carmodel , Car make, Car color, Car year.
- JAVA PROGRAMMING Write two java files for this assignment: Circle.java, and Main.java. The Circle.java file will create an actual class. The Circle class: MEMBER VARIABLE double radius double x double y Eight methods: Six of the methods are simple: getter’s and setter’s for x, y, and radius. There should also be a getArea method that returns the area (derived from the radius) A doesOverlap method. This method should accept a Circle as an argument, and return true if this circle overlaps the circle that the method was invoked on. [Note: two circles overlap if the sum of their radius' is greater than or equal to the distance between their centers.] void setX(double value) double getX() void setY(double value) double getY() void setRadius(double value) double getRadius() double getArea() boolean doesOverlap(Circle otherCircle) second class will be the typical replit Main class, with its static main method .It should contain code that tests the Circle class. submit code that…A class named boss has been defined as follows:public class Best {private int aNum; private int bNum; public Boss() { }public void setNums(int x, int y){aNum= x;bNum= y;}}Given the values of aNum and bNum are 13 and 72, write the toString() method for this class will display the class fields in the format below.The values of aNum= 13 and bNum= 72(Date Class) Create a class called Date that includes three pieces of information as datamembers—a month (type int), a day (type int) and a year (type int). Your class should have a constructor with three parameters that uses the parameters to initialize the three data members. For thepurpose of this exercise, assume that the values provided for the year and day are correct, but ensurethat the month value is in the range 1–12; if it isn’t, set the month to 1. Provide a set and a get function for each data member. Provide a member function displayDate that displays the month, dayand year separated by forward slashes (/). Write a test program that demonstrates class Date’s capabilities.
- public Account (double initialBalance){balance = initialBalance;}public Account () {balance = 0;}public void deposit (double amount){balance += amount; // Balance = balance + amount}public void withdraw (double amount){balance -= amount; // balance = balance - amount}public void close (){balance = 0;}public String toString(){return "balance: " + balance;}} Modify the Account class by adding two instance variables containing the customer's name and the account number. Both will be String objects. Modify the primary constructor for the Account class so that it takes three parameters: the balance, the customer's name, and the account number. Add instance methods named getCustomerName and getAccountNumber that return the customer name and account number.:Define and implement class Employee. This class should contain the following fields: first name, last name, employee id, hourly pay. This class should contain getters and setters for all its attributes. This class also needs at least one constructor. Implement method computePay() in this class. This method should accept an integer number of hours the employee worked as an input argument and return a floating point value indicating the pay the employee earned. If the number of hours is invalid (e.g. a negative number) this method should throw NumberFormatException. If the number of hours is over 40 then this method should throw a custom exception named TooManyHoursWorkedException. Remember that you will have to define your own exception class for this. Save this class and its definition into a file named Employee.java. Define and implement class EmployeeTest.This class should implement main() method. In the body of the main() method you should create an instance of Employee with the…C++ Write a class named Time It must have three private integer members named hours, mins and secs It must have a public constructor that sets the default time, hours, mins and secs to zero It must have two public member functions that are return type void. They must be settime with three integer arguments – this will allow the main function to reset the hours, mins and secs. show data with no arguments – this will allow the main function to display the time to the console. Use the main program as shown below to test your output against the output shown below:int main() { Time a, b, c (8,20,10); // declare 3 objects b.settime(1,8,3); // assign values to b's data members a.showdata(); // display object a's values b.showdata(); // display object b's values c.showdata(); // display object c's values return 0; }