Create a class having four private double data members

Assignment Help Computer Engineering
Reference no: EM131864556

Assignment

Requirement:

Create a class LastnameFirstnameA4.javaprogram having four private double data members - side1, side2, side3 and side4 storing the measures of sides of the quadrilateral.

Along with the constructor, the member methods in this class include:

lengthCompare() - returns an integer and compares the lengths of the sides.

If all the four sides are equal, you should let the user know that it's a square and go ahead with the other functions (perimeter and area)

If onlytheopposite sides are of same length,let the user know that it's a rectangle and go ahead with the other functions (perimeter and area)

If the sides are different, let the user know that it's a quadrilateral of different side lengths and only execute and print the perimeter function.
(Here, when we find all lengths equal or opposite lengths equal, we assume thatall the interior angles are right angles (?90?^0))

getPerimeter() - returns a double, perimeter of the quadrilateral
getArea() - returns a double, area of the quadrilateral (area only for square or rectangle)
print() - prints information as shown below (shows only 3 types - Square, Rectangle and Quadrilateral and rest of the information such as perimeter and area.)

You can pass arguments in the above functions wherever required.

In the main method of LastnameFirstnameA4.java create the objects of this class and call the function(s) necessary to print the required output as shown in the sample output.

Sample input:

LastnameFirstnameA4 Obj1 = new LastnameFirstnameA4(7, 4.1, 7, 4.1);
LastnameFirstnameA4 Obj2 = new LastnameFirstnameA4(2,2,2,2);
LastnameFirstnameA4 Obj3 = new LastnameFirstnameA4(1, 2, 3, 4);

Sample output:

(7, 4.1, 7, 4.1) is a rectangle
The Perimeter is22.200000000000003
The area is28.699999999999996

(2,2,2,2) is a square
The Perimeter is8.0
The Area is4.0

(1, 2, 3, 4) is a quadrilateral
The Perimeter is 10.0

Program Completed

Note:

1. The program should always print ‘Program Completed' before exiting.
2. Check if your program works properly by using different values for sides of the quadrilateral
3. There is no user input needed for this program.
4. Give comments to increase code readability.
5. Mention the sources used to complete the assignment.

Reference no: EM131864556

Questions Cloud

What is the purpose of a directional control valve : 1. What is the purpose of a directional control valve? 2. What is a check valve, and what does it accomplish?
What is a pressure-reducing valve : 1. What is a pressure-reducing valve. What is its purpose? 2. What does an unloading valve accomplish?
Calculate power supplied by the dependant voltage : EET 3086C – Circuit Analysis - Determine the numerical value for each current and voltage. Do not use Mesh or Node analysis
What is a pressure-compensated flow control valve : 1. What is a pressure-compensated flow control valve? 2. What is a servo valve? How does it work?
Create a class having four private double data members : Create a class having four private double data members - side1, side2, side3 and side4 storing the measures of sides of the quadrilateral.
What role do parents and teachers have in placement : What are the indicators of exceptionality a classroom teacher should look for when a student also has a language barrier?
What is a hydraulic fuse : 1. What is a hydraulic fuse? What electrical device is it analogous to?
Advantages of the shear-seal rotary directional control : 1. Name two advantages of the shear-seal rotary directional control valve as compared to the spool type.
How to utilize the medical resources to receive regular : How to utilize the medical resources to receive regular pediatric check-ups and screenings for children in the program.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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