Write a program to test your class myrectangle.

Assignment Help JAVA Programming
Reference no: EM13940996

Create a class named MyRectangle to represent rectangles. The required data fields are width, height, and color. Use double data type for width and height, and a String for color. Suppose that all rectangles are the same color. Use a static variable for color. You will need to provide the accessor methods for the properties and a method findArea() for computing the area of the rectangle.

Compile and run your program until it works and the output looks nice. Add the necessary documentation as described in Course Documents, and then attach your .java file to this assignment. Do not attach the .class file, attach only the .java source code.

The outline of the class is given as follows:

public class MyRectangle{

private double width = 1;
private double height = 1;
private static String color = "white";

public MyRectangle(){

}

public MyRectangle(double widthParam, double heightParam, String colorParam){

}

public double getWidth(){

}

public void setWidth(double widthParam){

}

public double getHeight(){

}

public void setHeight(double heightParam){

}

public String getColor(){

}

public static void setColor(String colorParam){

}

public double findArea(){

}
}

Write a program to test your class MyRectangle. In the client program, create two MyRectangle objects. Assign a width and height to each of the two objects. Assign the first object the color red, and the second, yellow. Display all properties of both objects including their area.

Reference no: EM13940996

Questions Cloud

Determine the stated interest rate on the bonds : Determine the stated interest rate on these bonds. Calculate the interest expense and the discount amortization for the interest period ending June 30, 2010.
Analysis on existing personal skills and knowledge : A SWOT analysis on existing personal skills and knowledge, and skills that need to be developed in the future in order to succeed in study and work.'
Formulate a research specification : Formulate a research specification with the following features: a) Title/research question.
Understanding of external and internal environments : You should demonstrate a clear understanding of the external and internal environments of your choice. What the Macro and Micro factors are and the kinds of influences each one includes.
Write a program to test your class myrectangle. : Compile and run your program until it works and the output looks nice. Add the necessary documentation as described in Course Documents, and then attach your .java file to this assignment. Do not attach the .class file, attach only the .java sourc..
Risk associated with each security independently : The management of Pitsos Ltd is considering the following two investments. The returns of these new projects depend on the state of the economy and they are shown below.
Determine what interest expense for the bond issue : Determine what interest expense for this bond issue Dingle will report in its 2010 income statement. Indicate how these bonds will appear in Dingle's December 31, 2012, balance sheet.
Determine a suitable receiver capacity : Determine a suitable receiver capacity if the maximum allowable number of starts per hour for the compressor is 20.
Criteria relevant to primark in their new market selection : Detail the macro and micro criteria that would be relevant to screen the markets. Why are these criteria relevant to Primark in their new market selection

Reviews

Write a Review

JAVA Programming Questions & Answers

  Develp a simple model of an object-oriented system

you are going to develp a simple model of an object-oriented system. this model should be able to provide all the working examples of inheritance, encapsulation, and polymorphism through the use of class,. methods, and objects

  Program designs used in developing java applications

program designs used in developing Java applications

  Write a reference class called ctatrain

writing a reference class that consist of the 2nd and 3rd instance variables below. my class should consist of an array of values in the 2nd instance variable

  Write a simple java program that will read an array of info

write a simple java program that will read an array of information containing the information (Name, offence [between arson, assault or theft] and year of offence

  Validation and event handling in javascrip

To complete this project you will write and submit one HTML file containing embedded CSS and JavaScript. The file will be called lab2.html. This file contains a registration form, which can be styled any way you like subject to the requirements be..

  Java enumeration lettergrade represent letter grades

Write a java enumeration LetterGrade that represents letter grades A through F, including plus and minus grades. Define a private instance variable holding a boolean value.

  Code that sorts the household sizes in ascending order

The program should allow the user to enter each household size and determine the mean and median household size in Marengo. Need to write the code that sorts the household sizes in ascending order using a bubble sort.

  Structure named dog with a string field

Create a Structure named dog with a string field for the Dog's name. Create a Structure named Cat with a string field for the Cat's name. Write a program that declares one Dog and one Cat, and assign names to them. Write two overloaded functions n..

  Write a complete java program to simulate ahmed''s show

Suppose you're on a game show and you're given the choice of three doors. Behind one door is a car; there is nothing behind the others. The car and is placed randomly behind the doors before the show. The rules of the game show are as follows:

  Luminous jewels - the polishing game

Once a jewel type is removed from the necklace, all other instances of the same jewel type is treated as polished by the person who removed the jewel

  Java program to write-read data from user using i-o function

Write java program to write and read data from user using I/O functions. Describe class with data members name[20],emp_id,basic pay,net pay.calculate all the allowances.

  Credit card expenses

You started recording every credit card transaction so that you can analyze your monthly expenses. You used an Excel worksheet to track dates, places, categories, and amounts. Because you are a consultant who travels periodically, you also have bu..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd