Write the Circle class:• A Circle has a radius – Add instance variable – 2 constructors – one should be the default or no args – Add accessor and mutator method for each instance variable – Add methods to calculate Area, Perimeter, and Diameter TestCircle Create a Circle with the radius Print the radius using the getters Print the Circle’s area, circumference, and diameter Change the circle’s radius Reprint the information
Q: Write a Hamster class that is a subclass of Pet. Include: an additional attributes called…
A: A class is a group of objects which have common properties. A constructor is a method that is used…
Q: B - RobotFriend Create a RobotFriend class. RobotFriend is a new toy just on the market. Copy the…
A: EXPLANATION: - The RobotFriend class Details: - Instance Variables Declaration private String…
Q: Define the Circle2DYourLastName class that contains: Two double data fields names x and y that…
A: Actually, array is a collection of elements.
Q: 1) Create a new Java Project named Final 2) Create a superclass VehicleRental a. Instance private…
A: Code: import java.text.DecimalFormat;class VehicleRental{ private int year; private String…
Q: Java Problem. compile and run the code below: /** A class to test the Door class. */ public…
A: Class definition: A class is a user-defined data type that contains the data members and methods.…
Q: Create an Employee Class that will have Two instance variable: name and workingPeriod • A class…
A: employee1 = Employee('Dororo',3)employee2 = Employee.employeeByJoiningYear('Harry',…
Q: Write a Person class. A Person has properties of name and age. You construct a Person object by…
A: To solve this question, we can frame the entire coding as below : Person.java //declaring a class…
Q: Design a class named StopWatch. The class contains:■ The private data fields startTime and endTime…
A: UML diagram for class :
Q: Design a class named Rectangle to represent a rectangle. The class must have the following: •…
A: Program: Filename: “Main.java” class Main { public static void main(String args[]) { Rectangle r1…
Q: Design a ‘book’ class with title, author, publisher, price and author’s royalty as instance…
A: The following program created in Java. Created book class. Created constructor of book class for an…
Q: The BankAccount class models an account of a customer. A BankAccount has the followinginstance…
A: Program: Filename: BankAccount.java // Import the required package import java.util.Date; // Class…
Q: Class: Square Create a class called "Square", which is inherited from “TwoDimensionShape”…
A: public abstract class TwoDimensionalShape { //creating abstract method which should be override by…
Q: . Make a class called MyCircle, which models a circle.The class contains: • One private instance…
A: Import java utility Create a class called My circle Class My circle has integer variable radius as…
Q: field for the number of sides of the die. A constructor that takes an integer between 4 and 20,…
A: A private field for the number of sides of the die. A constructor that takes an integer between 4…
Q: Java Object Oriented Programming Create a Shape class that shall have color and filled instance…
A: Answer in step2
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 class SavingsAccount. Use a variable annualInterestRate to store the annual interest rate for…
A: Hey, thank you for your question. As you have not mentioned any specific programming language we are…
Q: Write a Person class. A Person has properties of name and age. You construct a Person object by…
A: public class Person { String name; int age; public Person(String theName, int theAge) { this.name…
Q: Hint: In all your answers, implement all the methods out of the classes 1. Define a constructor with…
A: r is an array of Room objects and thus we can set the values of length and width of each room in…
Q: Construct a class named Circle with attributes named radius, diameter and area. Include a…
A: Dear Student, As no programming language is mentioned I am not assuming it to be java.
Q: Your task is to implement the following TouchNGo class. It is a subclass of DigitalWallet. The…
A: In this question we have to write a JAVA Program in which we have to write a class for TouchNGo…
Q: Create a RobotFriend class. RobotFriend is a new toy just on the market. Copy the starter class and…
A: The required class will have an instance variable "name". 'this' refers to the current object of the…
Q: Create a class named Book. The class have the following instance data members: o Book name o ISBN…
A:
Q: Create a class called Pyramid. A Pyramid is described by three pieces of private information as…
A: Here I have first of all created the class Pyramid with the data members as defined in the question.…
Q: A class RentedVehicle that has: 1.One private instance variable baseFee of type double 2.One…
A: The, code has given below:
Q: Creating a Class for Dates Create a class called Date212 to represent a date. It will store the…
A: Solution: Given, Create a class called Date212 to represent a date. It will store the year, month…
Q: Create the following classes (each in a separate .jave file) - Product, Book, Car and ProductTest…
A: The following classes have to be made: Product Book Car Class Book and class Car inherits from…
Q: Description what the JAVA should execute: Create a new project called Family. Add a person class…
A: Given: Now add a new instance variable to the Person class of type Person with the identifier…
Q: Create a TeeShirt class for Toby’s Tee Shirt Company. Fields include: orderNumber - of type int…
A: Program code: filename: TeeShirt.java //define a class TeeShirt public class TeeShirt {…
Q: (Rectangle Class) Create a class Rectangle with attributes length and width, each of which defaults…
A: Here, you need to create class called 'Rectangle' with attributes length and width. In this class,…
Q: The xxx_Pet classA Pet has a:– Name• Include an instance variable• Getters and setters for an…
A: Programming language is missing in the question. The below program is written in Java programming…
Q: (The HyPoint class) Design a class named MyPoint to represent a point with x- and y-coordinates. The…
A: Answer
Q: Create a subclass named Square from the superclass GeometricObject. Create an instance variable…
A: GeometricObject.java public abstract class GeometricObject {private String color = "white";private…
Q: Exercise 1 (textbook 8.4) (Rectangle Class) Create a class Rectangle with attributes length and…
A:
Q: Create a class “Main” having main method to perform following tasks. Create two objects of Subject…
A: Given: Create a class “Main” having main method to perform following tasks. Create two objects of…
Q: Create four (4) classes: • Main (where the main method is) • Shapes (Parent/Super class) • Square…
A: (a) import java.util.*;import java.lang.*;import java.io.*; class Shape{ public void method()…
Q: Create a subclass named Square from the superclass GeometricObject. Create an instance variable…
A: Sub Class is a class which inherits the other class. It is also called a derived class or child…
Q: Design and implementation of Java (Draw UML) classes 1. Design a class named Bill to represent a…
A:
Q: Write a class called Dog that contains instance data that represents the dog’s name and age. •…
A: Algorithm: Start Create a class Dog with name and age as its attributes Implement constructor to…
Q: A Door Class A computer game usually has many different objects that can be seen and manipulated.…
A: Q: Code the given problem
Q: Create a class with following attributes: The car's make The car's model The car's year
A: Java code: //create Car classclass Car{ //attributes String make; String model; int year;…
Q: Define a class named Randomwalker. A Randomwalker object should keep track of its (x, y) location.…
A: public class Tester{ public static void main(String args[]){ RandomWalker r1=new RandomWalker();…
Q: a java class name is Bugs that have Instance variables Constructors Automatic code generation…
A: Bugs regarding databases can lie in three areas: The GUI controls in Lazarus (DBGrid etc) The FPC…
Q: Write a Company class that has name, address and annual income as members. Write the following…
A: Algorithm : Company Class Step 1 : declare required date members. Parameterized constructor Step 1…
Q: Design a class named StopWatch. The class contains:■■ Private data fields startTime and endTime with…
A: Program: //class definition public class Exercise09_06 { //define main method public…
Q: The BankAccount class models an account of a customer. A BankAccount has the followinginstance…
A: Program code: Filename : BankAccount.java // Import the required package import java.util.Date;…
Q: (Car Class) Create a class called Car that includes three instance variables-a model (type String),…
A: /*-----CarApplication.java------*/ import java.util.Scanner;class Car{ String year, model;…
Q: Write a Dice class. The class should have: • A private field for the number of sides of the die • A…
A: Java used to answer this question
Q: * This class describes a tweet. A tweet has a message in it, a unique ID, * a count of the number of…
A: EXPLANATION: - The Tweet class comprises instance variables of the following instance variables: -…
Write the Circle class:
• A Circle has a radius
-
– Add instance variable
-
– 2 constructors – one should be the default or no args
-
– Add accessor and mutator method for each instance variable
-
– Add methods to calculate Area, Perimeter, and Diameter
TestCircle
-
Create a Circle with the radius
-
Print the radius using the getters
-
Print the Circle’s area, circumference, and diameter
-
Change the circle’s radius
-
Reprint the information
Trending now
This is a popular solution!
Step by step
Solved in 7 steps with 6 images
- a. Write a FractionDemo program that instantiates several Fraction objects and demonstrates that their methods work correctly. Create a Fraction class with fields that hold a whole number, a numerator, and a denominator. In addition: Create properties for each field. The set access or for the denominator should not allow a 0 value; the value defaults to 1. Add three constructors. One takes three parameters for a whole number, numerator, and denominator. Another accepts two parameters for the numerator and denominator; when this constructor is used, the whole number value is 0. The last constructor is parameterless; it sets the whole number and numerator to 0 and the denominator to 1. (After construction, Fractions do not have to be reduced to proper form. For example, even though 3/9 could be reduced to 1/3, your constructors do not have to perform this task.) Add a Reduce() method that reduces a Fraction if it is in improper form. For example, 2/4 should be reduced to 1/2. Add an operator+() method that adds two Fractions. To add two fractions, first eliminate any whole number part of the value. For example, 2 1/4 becomes 9/4 and 1 3/5 becomes 8/5. Find a common denominator and convert the fractions to it. For example, when adding 9/4 and 8/5, you can convert them to 45/20 and 32/20. Then you can add the numerators, giving 77/20. Finally, call the Reduce() method to reduce the result, restoring any whole number value so the fractional part of the number is less than 1. For example, 77/20 becomes 3 17/20. Include a function that returns a string that contains a Fraction in the usual display format—the whole number, a space, the numerator, a slash (D, and a denominator. When the whole number is 0, just the Fraction part of the value should be displayed (for example, 1/2 instead of 0 1/2). If the numerator is 0, just the whole number should be displayed (for example, 2 instead of 2 0/3). b. Add an operator*() method to the Fraction class created in Exercise 11a so that it correctly multiplies two Fractions. The result should be in proper, reduced format. Demonstrate that the method works correctly in a program named FractionDemo2. c. Write a program named FractionDem03 that includes an array of four Fractions. Prompt the user for values for each. Display every possible combination of addition results and every possible combination of multiplication results for each Fraction pair (that is, each type will have 16 results).Create a PhoneListing class that uses the Name class for one of its instance variables. Remember the instance data in the Name class is private to the class and must be accessed through its methods.Add additional instance variables to the PhoneListing class for the phone number. The phone number should be broken down into three parts, area code, city code, and local code.Create all appropriate methods for the new class, including the following three methods: equals(PhoneListing):boolean, an equality of state method that returns true if the objects contain the same name and phone number. compareTo(PhoneListing):int, a comparison method that returns -1 if the calling PhoneListing object should precede the argument PhoneListing object, 1 if the calling PhoneListing object should come after the argument PhoneListing object, and a 0 if they are equal. Use last, first, middle, phone number as the ordering values. example:Adams, Alex, Henry, (609)473-2101 Adams, George, Henry, (509)373-1101…Class: Square Create a class called "Square", which is inherited from“TwoDimensionShape” class. The "Square" class is used to calculate theArea and the Perimeter of square shapes when their side-length is given, or in contrast,finding the side-length of the square when the Area or the Perimeter of the square is given.The specifications of this class are below. Data Members (Attributes): All are private. sideLength: the sidelight (L) of the square. Methods/Operations/Getters/Setters: Default Constructor: when creating an object this constructor must set the side-length of the square by calling the method setSideLength(). Also, this constructor willcall the findArea() and the findPerimeter() in addition to summaryPrint() to calculateand print all needed information. User-Defined Constructor: when creating an object this constructor shouldfind the side-length of the square by calling the method findSquareSideLength()and pass the Area or the…
- Create a RobotFriend class. RobotFriend is a new toy just on the market. Copy the starter class and the tester from Codecheck. A RobotFriend has a name and replies to various commands Provide a constructor that takes the name of the RobotFriend as a parameter. Remember that a constructor has the same name as the class. What does the class need to remember? That is the instance variable. Provide the following methods: public String getName() gets the name of this RobotFriend public void setName(String newName) sets a new name for this RobotFriend public String whatDoYouNeed() returns a string consisting of name + " needs a battery charge" where name is the name of this RobotFriend (which was supplied in the constructor) public String doCommand(String whatToDo) returns a string consisting of "Your friend " + name + " does not " + whatToDo where name is the name of this RobotFriend and whatToDo is the parameterWrite the Circle class:• A Circle has a radius– Add instance variable– 2 constructors – one should be the default or no args– Add accessor and mutator method for each instance variable– Add methods to calculate Area, Perimeter, and Diameter– Write a printArea method in the main program which receives an object circleand “times” integer– printArea() will print the radius and area of objects “times” time by changingthe radius of object.public static void printAreas(Circle c, int times) {System.out.println("Radius \t\t Area");while (times>=1) {//print the radius and area here// create a new object by changing the radius heretimes--;}}//end of printAreasThe xxx_Pet classA Pet has a:– Name• Include an instance variable• Getters and setters for an instance variable• A toString method which returns a String containing the pet name Abstract methods: speak() and move()The subclassesWrite a dog, cat, snake subclasses with proper instant variables and methodsWrite a class xxx_TestPet which will1- Create a dog, a snake, and a cat objectsSample OutputPet Fido is a dog, weighing 45 poundsFido says woofrun Fido runPet Sam is a snake, 30 inches longSam says hissslither Sam slitherPet Hershey is a cat, with Long hairHershey says Meowprance Hershey prance2- Print just the weight of the Dog, the length of the Snake and the hair length of theCat as shown belowFido weighs 45 poundsSam has length 30 inchesHershey has Long hair 3- Store the objects in an Array of Pet objects and print the information belowPet D1 is a dog, weighing 55 poundswoofrunPet S1 is a snake, 30 inches longhissslitherPet C1 is a cat, with Long hairmeowprancePet D2 is a dog,…
- Java Object Oriented Programming Create a Shape class that shall have color and filled instance variables of enum Color and boolean type. The filled boolean variable shall show, whether the shape is filled (colored). The enum Color shall be defined within the class having 4 color names (choose any four). Also define getArea and getPerimeter method in Shape class, both shall return 0. Create Rectangle class with length and width attributes and a Circle class with radius attribute, of type double. Properly encapsulate all fields. Circle and Rectangle shall extend Shape class and override getArea and getPerimters methods as per its type and specific formula. In Test class, create an object of Rectangle and Circle, by initializing all attributes in constructor and print both shapes' area and perimters. In Test class, define a static method with following signature, public static void printEachShapeCount(Shape... shapes) As you know, the parent type variable can hold the…using c++ oop !!! kindly need help asap. Implement the shape, rectangle, and square classes with components as shown and the following functionality: Each constructor and destructor prints a message to the screen that it is being called in each class implement the area() method that calculates the area of the figure (for the Shape class you can return 0) Example Constructor shape: Rectanleeeeeee Rectangle constructor 232.5 Rectanleeeeeee Eeeeeeee Rectangle destructor Shape destructor Constructor shape: Squareeeee Rectangle constructor Square constructor Squareeeee AAAaaaa 105.165 Square destructor Rectangle destructor Shape destructor // main.cpp : Defines the entry point for the application.// #include "main.h"using namespace std; int main(void) {{rectangle rec("Rectanleeeeeee", 10, 23.25);std::cout << rec.area() << std::endl;std::cout << rec.get_name() << std::endl;rec.set_name("Eeeeeeee");std::cout << rec.get_name() << std::endl;} {square…Create a subclass named Square from the superclass GeometricObject. Create an instance variable named width with initial value 0. Create a no-arg constructor. Create the another constructor, which has one parameter named wid. Assign the wid to the instance variable named width. Create the getWidth() method, the setWidth() method. Override the getArea() method. Override the getPerimeter() method. Create a test class named Test to create an instance with wid= 6 from Square class. Call the getArea() and getPermeter() methods to print out the area and perimeter of the square with width=6.
- The BankAccount class models an account of a customer. A BankAccount has the followinginstance variables: A unique account id sequentially assigned when the Bank Account is created. A balance which represents the amount of money in the account A date created which is the date on which the account is created.The following methods are defined in the BankAccount class: Withdraw – subtract money from the balance Deposit – add money to the balance Inquiry on:o Balanceo Account ido Date createdThe SavingsAccount class models a bank account which is meant for long term savingsand earns interest. It inherits all the fields and methods of the BankAccount class. TheSavingsAccount class has an additional instance variable, interest rate. The interest rate is adecimal representing the rate at which the account earns interest. For example, an interestrate of .01 means that the account will earn 1% interest on its balance.The following additional methods are defined in the SavingsAccount…The BankAccount class models an account of a customer. A BankAccount has the followinginstance variables: A unique account id sequentially assigned when the Bank Account is created. A balance which represents the amount of money in the account A date created which is the date on which the account is created.The following methods are defined in the BankAccount class: Withdraw – subtract money from the balance Deposit – add money to the balance Inquiry on:o Balanceo Account ido Date createdThe SavingsAccount class models a bank account which is meant for long term savingsand earns interest. It inherits all the fields and methods of the BankAccount class. TheSavingsAccount class has an additional instance variable, interest rate. The interest rate is adecimal representing the rate at which the account earns interest. For example, an interestrate of .01 means that the account will earn 1% interest on its balance.The following additional methods are defined in the SavingsAccount…THIS NEEDS TO BE DONE IN JAVA! Create a class called Employee that includes three instance variables—a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. Write a test app named EmployeeTest that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10% raise and display each Employee’s yearly salary again.