Design a class named Rectangle to represent a rectangle.
Q: Please help in JAVA!!! Create a Java class called Block that contains two fields named baseSide and…
A: ALGORITHM:- 1. Define the class Block with the appropriate methods. 2. Declare the object of Block…
Q: Create a class named Person that holds the following fields: two String objects for the person’s…
A: package Java.C.c; import java.time.LocalDate; class Couple { privatePersonbride;…
Q: So, the problem is: Create a class named BloodData that includes fields that hold a blood type (the…
A: class BloodData{private String bloodType,RhFact; public BloodData(){bloodType = "O";RhFact = "+";}…
Q: design a class named Rectangle to represent a rectangle. The class contains: A method named…
A: Since the Programming language is not mentioned in the question, we will answer this question in…
Q: . Define a class named Book that represents a book about Java Programming Language, and it contains:…
A: Here, I have to write a java program to the above question.
Q: Design a class named MyPoint to represent a point withx- and y-coordinates. The class contains:■■…
A: UML Diagram:
Q: (A) Write a class called Course having data members: courseNum (String such as ITCS214), courseName…
A:
Q: Following the example of the Rectangle class of Chapter 9 Exercise 1, design a class named Cuboid to…
A: PROGRAM INTRODUCTION: Define the class with the name cuboid. Declare the required constructor that…
Q: The goal of this problem is to repackage most of the previous code as a class that extends JFrame.…
A: /* Java GUI program to print a message on console when a button is clicked*/ /* Program without…
Q: Hello, I have to Design a class name Rectangle to represent a rectangle. The class contains: Two…
A: We need to write a program for given scenarios with uml diagram. The code has been written in…
Q: Write a program in BlueJ using the following hints. 1. Create a class named Book and declare the…
A:
Q: Design a class named MyPoint to represent a point with X- and y-coordinates. The class contains: The…
A: The answer is given below:-
Q: (The Rectangle class) Following the example of the Circle class in Section 8.2, design a class named…
A: PROGRAM EXPLANATION: Create a Rectangle class. Declare all the data members for this class as given…
Q: The goal of this problem is to repackage most of the previous code as a class that extends JFrame.…
A: /* Java GUI program to print a message on console when a button is clicked*/ /* Program without…
Q: In this question you will develop the foundations of a custom java class called Stock with the…
A: Here, you need to write one java class called 'Stock' which consists four private variables/fields.…
Q: Write a program in BlueJ using the_following hints. 1. Create a class named Book and declare the…
A: The Answer to the Following Problem :-
Q: Construct a class named TestCirde whose main() method dedares THREE (3) Cirde objects. Using the…
A:
Q: Create a class called Employee that includes three pieces of information as instance variables—a…
A: Program is coded in Java language. There are 2 classes Employee.java and EmployeeTest.java, Run…
Q: reate a class called Date212 to represent a date. It will store the year, month and day as integers…
A: Given Create a class called Date212 to represent a date. It will store the year, month and day…
Q: Assignment 2 Make a new class called Buffet which posses all the methods and attributes of the…
A: Given:
Q: Write the definition of a class named WeatherForecast that has the following methods: • An_init_…
A: The Answer start from step-2.
Q: Create a class called Employee that includes three pieces of information as instance variables—a…
A: Define a class. Declare private type string variables along with a double type variable. Define…
Q: Implement a class named Rectangle to represent a rectangle using Java 1) Class name: Rectangle;…
A: Program description: The objective of the program is to create two classes namely, Rectangle.java…
Q: Which of the following statements correctly shows the first line of a class definition for…
A: Which of the following statements correctly shows the first line of a class definition for…
Q: Create a class called FinalGrade that is used to represent the points obtained in the letter grade…
A: Since Programming Language choice is not specified, we will be answering this question using C++…
Q: Following the example of the Rectangle class of Chapter 9 Exercise 1, design a class named Cuboid to…
A:
Q: Q1/ write a program to define a class called Facebook that has the properties personName and…
A: Program Approach: Create a class named Facebook with properties personName, personAge and…
Q: 1. Create a class named Student that has fields for an ID number (idNumber), number of credit hours…
A: NOTE: SINCE THE LANGUAGE OF THE CODE IS NOT MENTIONED, I HAVE USED JAVA FOR THE SOLUTION. Import…
Q: a class, Team.java, that has the following: * two private instance variables: a String named color…
A: // Java Code: import java.io.*; class Team{ //declaring the private variables private String color;…
Q: Carly's Catering provides meals for parties and special events. In Chapter 3, you created an Event…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Q4. The classes DateInfo and Student in different packages
A: Here is the solution which is mentioned below:
Q: In this project, try to use classes to design an online address book to keep track of the name,…
A: answer is given below
Q: Write a class named Taxicab that has three private data members: one that holds the current…
A: A Python docstring is a string used to document a Python module, class, function or method, so…
Q: Create a Shape class that shall have color and filled instance variables of enum Color and boolean…
A: The programming instructions are as follows: Define a super class Shape using the given…
Q: * In your main class: - Define a method called printItemDetails that takes an object of type Item…
A:
Q: Question#2: Define a class, mcmLength, to represent a length measured in meters, centimeters, and…
A: This is the Point class definition. It is used by the Rectangle class // Create a Point object…
Q: This is the question I am struggling on - Create a class named Horse that contains the following…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Following the example of the Circle class in Section 9.2 , design a class named Stock that contains:…
A: package com.java; public class Stock { private String symbol; private String name; private…
Q: Given this class, please add the requested methods in the designated spaces provided. Instance…
A: public class Student { // declare instance variables here private int ID; private String…
Q: Write a class encapsulating the concept of a television set, assuming a television set has the…
A:
Q: Next, create class Lab14A with a main method or driver which should do the following: Create two…
A: The program for the above given question is given below:
Q: Write a class called Name that has one instance variable to store the full name of a person. A name…
A: Program Explanation: Define a class for name Declare and define instance variables and constructors…
Q: Write a class called Pants that contains the following information: 1. Private instance variables…
A: use throw new IllegalArgumentException() to throw this kind of exception when input is beyond range.…
Q: Given the class definitions of MPoint and Named Point below, which of the constructors would be…
A: We have the class with name MPoint . We have two member variables inside it myX and the myY .Then…
Q: Write a class called person, which contains: A private class variable, Counter, initialized with…
A: //C++ program#include <iostream> using namespace std; class person{ //class variable…
Q: Assume there is a class Phone with a private attribute named model. Write a method named someMethod…
A: Given:
Q: Following the example of the Rectangle class of Chapter 9 Exercise 1, design a class named Cuboid to…
A: public class Cuboid { private int length,width,height; Cuboid(int length,int…
Q: Write a class named WeightCheck which contains the following: 1. Instance variables: name (String)…
A: public class WeightCheck { private String name; private char sex; private double height; private…
Q: Create a class called Triangle that has two private instance variables: base and height (double).…
A: The variables declared here are private. Private variables can only be accessed by the class in…
Design a class named Rectangle to represent a rectangle. The class contains:
- Two double data fields named side1 and side2 that specify the width and height of the rectangle. The default values are 1 for both side1 and side2.
- Public set and get methods for each of the 2 data fields.
- A no-arg constructor that creates a default rectangle.
- A constructor that creates a rectangle with the specified side1 and side2.
- A method named getArea() that returns the area of this rectangle.
- A method named getPerimeter() that returns the perimeter.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- (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.Design a class named MyPoint to represent a point withx- and y-coordinates. The class contains:■■ The data fields x and y that represent the coordinates with getter methods.■■ A no-arg constructor that creates a point (0, 0).■■ A constructor that constructs a point with specified coordinates.■■ A method named distance that returns the distance from this point to aspecified point of the MyPoint type.■■ A method named distance that returns the distance from this point toanother point with specified x- and y-coordinates.■■ A static method named distance that returns the distance from two MyPointobjects.Draw the UML diagram for the class then implement the class. Write a testprogram that creates the two points (0, 0) and (10, 30.5) and displays the distancebetween them.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.)
- a. Carly's Catering provides meals for parties and special events. In Chapters 3 and 4, you created an Event class for the company. Now, make the following changes to the class: Currently, the class contains a field that holds the price for an Event. Now add another field that holds the price per guest, and add a public method to return its value. Currently, the class contains a constant for the price per guest. Replace that field with two fields—a lower price per guest that is $32, and a higher price per guest that is $35. Add a new method named isLargeEvent() that returns true if the number of guests is 50 or greater and otherwise returns false. Modify the method that sets the number of guests so that a large Event (more than 50 guests) uses the lower price per guest to set the new pricePerGuest field and calculate the total Event price. A small Event uses the higher price. Save the file as Event.java. b. In Chapter 4, you modified the EventDemo class to demonstrate two Event…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 reference of any child class object. That…The Rectangle class) Following the example of the Circle class in Section 9.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 and height 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 test program 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.
- Create a class named Lease with fields that hold an apartment tenant’s name, apartmentnumber, monthly rent amount, and term of the lease in months. Include a constructor thatinitializes the name to “XXX”, the apartment number to 0, the rent to 1000, and the term to12. Also include methods to get and set each of the fields. Include a nonstatic methodnamed addPetFee() that adds $10 to the monthly rent value and calls a static methodnamed explainPetPolicy() that explains the pet fee. Save the class asLeaseYourlastname.java. Replace ‘Yourlastname’ with your real last name.b) Create a class named TestLease whose main() method declares four Lease objects. Call agetData() method three times. Within the method, prompt a user for values for each fieldfor a Lease, and return a Lease object to the main() method where it is assigned to one ofmain()’s Lease objects. Do not prompt the user for values for the fourth Lease object, but letit continue to hold the default values. Then, in main(), pass…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); }Following the example of the Rectangle class of Chapter 9 Exercise 1, design a class named Cuboid to represent a cuboid. The class contains: Three data fields named length, width, and height. A constructor that creates a cuboid with the specified length, width, and height. A method named getVolume() that returns the volume of this cuboid. Then, please create an object mycuboid = Cuboid (2, 3, 4), and invoke getVolume to print the volume of mycuboid.
- Implement a class named Rectangle to represent a rectangle using Java 1) Class name: Rectangle; accessibility: public 2) The class contains: Two private double data fields named width and height that specify the width and height of the rectangle. 3) A no-arg constructor that creates a default rectangle: data fields are 1 for both width and height. 4) A constructor that creates a rectangle with the specified width and height. 5) A public method named setWidth that sets the value of width 6) A public method named getWidth that returns the value of width 7) A public method named setHeight that sets the value of height 8) A public method named getHeight that returns the value of height 9) A public method named getPerimeter() that returns the perimeter. 10) A public method named getArea() that returns the area of this rectangle. 11) Draw the UML class diagram 12) Write a test file that creates two Rectangle objects: one with width 4 and height 40 and the other with width 3.5 and…Design a public class named Rectangle to represent a rectangle following the example of the Circle class we did in Lesson #5. The Rectangle class contains:• Data fields:o private double data field width with default value 2o private double data field length with default value 3• Two constructor methods:o A no-argument constructor that creates a default rectangle with the default valueso A constructor that creates a rectangle with the specified width and length in the formal parameters• Instance methods:o A public method named getPerimeter() that returns the perimeter of the rectangle (double)o A public method named getArea() that returns the area of the rectangle (double)o Public getter methods to access the data fields, specifically:▪ getWidth()▪ getLength()o Public setter methods to set the data fields to values passed in▪ setWidth (double newWidth)▪ setLength(double newLength)INFO 1214 –Assignment 3Page 2Write a simple test program call TestRectangle like we did in class that…Create a class named Student that has fields for an ID number, numberof credit hours earned, and number of points earned. (For example,many schools compute grade point averages based on a scale of 4, so athree-credit-hour class in which a student earns an A is worth 12 points.)Include methods to assign values to all fields. A Student also has a field forgrade point average. Include a method to compute the grade point averagefield by dividing points by credit hours earned. Write methods to display thevalues in each Student field. Save this class as Student.java.b. Write a class named ShowStudent that instantiates a Student object from theclass you created and assign values to its fields. Compute the Student gradepoint average, and then display all the values associated with the Student.Save the application as ShowStudent.java.c. Create a constructor for the Student class you created. The constructor shouldinitialize each Student’s ID number to 9999, his or her points earned to 12,…