Question

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.

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Java

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: You will find the files needed for Problems 1 and 2 in the Module 8: Graphical User Interfacescourse...

A: Actually, java is a object oriented programming language. It is a platform independent.

Q: Write a  C program to sort the words in a string and the print the sorted string in alphabetical ord...

A: EXPLANATION - Create a function named with  func that is user defined function . The printf() will d...

Q: Suppose you have a set of search keys are encoded like as "IaIPOIP6P8PLP9PSP+PEPTPIP Here D1-D11= to...

A: Insertion in B+ tree:- 1. Insert the new node as the leaf node.  2. Go on inserting at the same leve...

Q: This is the question -  Write an application in which you declare an array of eight first names. Wri...

A: GIVEN: Create a Java program and declare an array of eight first names. Write a try block. Get the i...

Q: Question 2Can we have option for Rewritable Optical Discs? If we have so how could this possible to ...

A: Solution: A electronic data storage medium which an write and read data  with the help of low-powere...

Q: Solve this problem

A: Actually, java is a object oriented language. It is a platform independent.

Q: It is a Question from Discrete Mathematics , Topic Nested Quantifiers

A: (a) $\forall x \forall y((x < 0) \wedge(y < 0) \rightarrow(x+y<0))$(b) $\exists x \exists y...

Q: Scilab program for solving ordinary diffrential equation using ode package

A: It is numerically oriented high level programming language. It is free and open source software for ...

Q: Amarillo Video Store is planning a promotional give-away for its long-standing customers. If the cus...

A: Decision Tree: It is a tree structure of various conditions that are considered to make a decision. ...

Q: The intersection of two sets contains the list of elements that are common to both, without repetiti...

A: Intersection: Let A and B the two arrays that store the sets of A and B respectively and C be the ar...

Q: What is a computer virus? What is a worm?

A: VIRUS stands for Vital Infection Resources Under Sieze A computer virus, much like a flu virus, is d...

Q: Why is Burberry's Digital Strategy So Good?

A: Burberry's Digital Strategy is a great way to promote the brand to a key target audience and encoura...

Q: Sentiment analysis is a very effective way to enhance and develop your business using the client fee...

A: Here in this question context diagram for an Online Application system has to be built  that applies...

Q: Write a Java or C++ program that will display the given menu: A Simple Library System1. Add a Studen...

A: Actually, java is a object oriented programming language. It is a platform independent.

Q: Complete the following applied optimization word problem. Include a well-labeled figure, clearly def...

A: Actually, the given information is: To mail a package with the United States Postal service without ...

Q: The three-layer architecture has the primary objective of separating each user’s view of the databas...

A: Click to see the answer

Q: using simple loop    Write a c++ program that takes 10 character type input from user. In the end, y...

A: #include<iostream> using namespace std; void Count(string str) { int upper = 0, lower = 0, ...

Q: What is the benefits and drawbacks of using IPSec over other network security mechanism such as thos...

A: Advantages of IPSec 1. Network layer securityIPSec operates at layer 3, the network layer. As a resu...

Q: Q1: Suppose x = 3 and y = 2. Show the output, if any, of the following code. What is the output if x...

A: Step 1:- The flowchart is a graphical way to explain the flow of data of the program. We are using d...

Q: TIME CLASS (Language: C++) - Write a time class named timeClass  - Write code to demonstrate that it...

A: Program: Filename: Main.java   import java.util.*; import java.lang.*; import java.io.*;   class Mai...

Q: Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a dou...

A: Objective: we need to create a Salesperson class that has an id number and annual sales mount.Also c...

Q: Clustering is a side effect of linear probing. Group of answer choices True False

A: True

Q: Implement the below class. Car- plateNumber: String- horsePower: int- year: int- nbCarsCreated: int+...

A: The required Java code is given below: public class Car {                      // class Car definiti...

Q: Write microC program to 8 bits up counter using pic16f84a

A: Actually, 1 byte=8 bits.

Q: python question, where i did wrong??? i couldn't find problem

A: def main   main

Q: The Internet has fast become a key instrument for the exercise of the right to freedom of speech. In...

A: Freedom of speech is a principle that encourages an individual's or a community's freedom to express...

Q: Draw the diagram of given addressing mode. Show it with examples also. 1.  Nested Indirect Addressin...

A: In  Nested Indirect Addressing mode, the address of the operand which is needed to be used in the in...

Q: Write a C program, called msg.c, that reads messages from an input file (or stdin) and verifies whet...

A: Actually, program is a executable software that runs on a computer. 

Q: Describe a utility-based agent for an autonomous delivery robot. You must describe thefollowing for ...

A: As per the policy, we can answer only the first three subparts, so answers are below- How the utilit...

Q: How do I input a CSV file into an array in Java? The CSV file has the following columns: Drug Name, ...

A: Actually , given information is: There is also 150 rows of data. All of this needs to be stored in s...

Q: Write a user-defined function that adds or subtracts two polynomials of any order. Name the function...

A: Actually, user defined function is a function defined by user

Q: A set of eight data bytes is stored in memory locations starting from XX70H. Write a program to add ...

A: Given: A set of eight data bytes is stored in memory locations starting from XX70H. Data(H) F9, 38,...

Q: a) Write a method encrypt(String text, int key) that returns a String. This method does two things t...

A: public static String encrypt(String text, int key) {  String temp[] = text.split(" ");  String rever...

Q: Object is name(age,time) For example : apple (1,11)  the Binary tree order depend on age Write a jav...

A: An object in Java is the physical as well as a logical entity. An object has three characteristics: ...

Q: Create a CourseException class that extends Exception and whose constructor receives a String that h...

A: public class Course {private String department;private int courseNumber;private float credits;public...

Q: Write bash script which takes array as an input of size 10 bind its even indexes to accept even valu...

A: The, script has given below;

Q: need code in C++ answer all parts Assume the Product structure is declared as follows: struct Produc...

A: I have solved the first 4 parts of the question, please post parts 5 to 7 in a separate post and I w...

Q: Convert the following into Pep/9 Assembler: #include <iostream>using namespace std;int square(...

A: Converted Code: _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@plt:  jmpq   *0x2fe2(%rip...

Q: Compare 0-, 1-, 2-, and 3-address machines by writing programs to computeX = (A x B + C) / (D − E × ...

A: //Assemble Language Code 3 Address 2 Address  1 Address(ACCUMULATOR) 0 Address(STACK MACHINE) Loa...

Q: Explain the benefits of hierarchial routing in terms of scale and administrative autonomy.Differenti...

A: Note: This question contains the multiple questions. According to the guidelines you will get the an...

Q: Code in C# (OOP Concept) Suppose that Fruit, Apple, Orange, GoldenDelicious, and McIntosh are define...

A: What is an instance(object):- (OVERVIEW) A class defines a type of object, but it is not an object i...

Q: Your program should read the specifications of graphic objects from a text File provided by the user...

A: Actually, java is a object oriented programming language. It is a platform independent.