Create two subclasses of shape- circle and square

Assignment Help Computer Engineering
Reference no: EM132076092

Need help with this java program

use the code below to solve this problem

The Shape class is abstract and contains o ne method: getArea. Your task is to create two subclasses of Shape: Circle and Square. Then, you should write a driver program with a main method that creates an array capable of holding four Shape objects.

Populate your array with two Circle objects and two Square objects. Finally, call the getArea method on each Shape in your array and display the results You should not make any changes to Shape.java.

Hints: In case you have repressed your memories of geometry class, the area of

a circle is pi times the radius squared, where pi is approximately 3.14159. Java has the value of pi stored more accurately as the constant Math.PI. The area of a square is the length of its side, squared. You will likely need to declare fields in your Circle and Square classes to hold the radius and side length, respectively.

You will also need constructors for each class, to initialize the fields of the class.

Example Assume your array of Shape object contains the following:

A circle with a radius of 1

A circle with a radius of 5.27

A square with a side of length 14

A square with a side of length 10

Then the output of your driver program should be:

3.141592653589793

87.25113860888395

196.0

100.0

here is the code so far:

******lab.pkg1.practice.starting.code******(driver class)

package lab.pkg1.practice.starting.code;

public class Lab1PracticeStartingCode {

public static void main(String[] args) {
// TODO write code here to create an array of four Shape objects,
// call the getArea method of each one, and display the results.
}

}

*****shape.java*******

package lab.pkg1.practice.starting.code;

public abstract class Shape {

public abstract double getArea();
}

Reference no: EM132076092

Questions Cloud

Global supply chain logistic and international logistics : Select a Company involved in Global Supply Chain Logistic and International Logistics. Write a paper on the journey to becoming a partner in International Logis
Implementing voice recognition technologies : What are some of the benefits afforded to organizations implementing voice recognition technologies in these settings?
Organizations implementing voice recognition technologies : What are some of the benefits afforded to organizations implementing voice recognition technologies in these settings?
What are the concepts and theories behind maximizing : What are the concepts and theories behind maximizing productivity and positive attitudes during the change process? Be sure to use the proper terminology in you
Create two subclasses of shape- circle and square : Create two subclasses of Shape: Circle and Square. Then, you should write a driver program with a main method that creates an array capable of holding.
Increasingly making use of cloud technology : Small businesses are increasingly making use of cloud technology solutions (also known as software as a service, or SaaS)
Current human resource management : You will write a synopsis (summary) of the current Human Resource Management (HRM) academic research on a contemporary HRM topic
Create and call a void method that stores five million : Create and call a void method (or methods) that stores 5 million random integers in a linked list.
Theory of constraints to supply chain collaboration : Describe how the Theory of Constraints (TOC) works in a manufacturing supply chain like Maple Excellence Furniture Company

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