Need help developing the following in Java:
Create an abstract class "Shape" with the following specifications:
- An abstract method "surface_area ()" of return type double
- An abstract method "volume()" of return type double
Put your code in a Java source file named "Shape.java."
I.
Create a class "Sphere" that extends the Shape class with the following specifications:
- Attributes:
- Radius
- Constructor:
- Implement a parameterized constructor needed to initialize the data.
- toString:
- Implement a "toString" method that prints out the surface area and volume.
Implement methods to compute the surface area and volume.
II.
Create a class "Cylinder" that extends the Shape class with the following specifications:
- Attributes:
- Radius, height - both of type double
- Constructor:
- Implement a parameterized constructor to initialize the data.
- toString:
- Implement a "toString" method that prints out the surface area and volume.
Implement methods to compute the surface area and volume.
III.
Create a class "Cone" that extends the Shape class with the following specifications:
- Attributes:
- Radius, height - both of type double
- Constructor:
- Implement a parameterized constructor to initialize the data.
- toString:
- Implement a "toString" method that prints out the surface area and volume.
Implement methods to compute the surface area and volume.
IV.
Create a driver class named "ShapeArray" with the following specifications:
- Instantiate one sphere.
- Instantiate one cylinder.
- Instantiate one cone.
- Store the class instances into an array named "shapeArray."
- Loop through the array and print out the instance data of each object using the object instance's "toString" method.
Trending nowThis is a popular solution!
Step by stepSolved in 7 steps with 1 images
Is it possible to add a GUI interface for the program?
Can comments be added to describe the functionality of each class/method and any other important detail worth knowing about? Also, does the
Thank you
Can there be any improvements to the code to maximize efficiency, readability, and maintainability? What would that look like?
Is it possible to add a GUI interface for the program?
Can comments be added to describe the functionality of each class/method and any other important detail worth knowing about? Also, does the
Thank you
Can there be any improvements to the code to maximize efficiency, readability, and maintainability? What would that look like?
- Goal 1: Update the Fractions Class Here we will overload two functions that will used by the Recipe class later: multipliedBy, dividedBy Previously, these functions took a Fraction object as a parameter. Now ADD an implementation that takes an integer as a parameter. The functionality remains the same: Instead of multiplying/dividing the current object with another Fraction, it multiplies/divides with an integer (affecting numerator/denominator of the returned object). For example; a fraction 2/3 when multiplied by 4 becomes 8/3. Similarly, a fraction 2/3 when divided by 4 becomes 1/6. Goal 2: Update the Recipe Class Now add a private member variable of type int to denote the serving size and initialize it to 1. This means all recipes are initially constructed for a single serving. Update the overloaded extraction operator (<<) to include the serving size (sample output below for an example of formatting) . New Member functions to the Recipe Class: 1. Add four member functions…arrow_forwardCode: import java.util.*; //Bicycle interface interface Bicycle { abstract void changeCadence(int newValue); //will change value of candence to new value abstract void changeGear (int newValue); //changes gear of car abstract void speedUp(int increment); //increments speed of car by adding new Value to existing speed abstract void applyBrakes(int decrement); } //ACMEBicycle class definition class ACMEBicycle implements Bicycle { int cadence = 0; Â Â int speed = 0; Â Â int gear = 1; //methods of interface public void changeCadence(int newValue) { this.cadence=newValue; } public void changeGear (int newValue) { this.gear=newValue; } public void speedUp(int increment) { this.speed+=increment; } public void applyBrakes(int decrement) { this.speed-=decrement; } //display method void display() { System.out.println("Cadence: "+this.cadence); System.out.println("Gear: "+this.gear); System.out.println("Speed: "+this.speed); } } //KEYOBicycle class definition class KEYOBicycle implements…arrow_forwardInheritance and polmorphism: In Java, Using Classes, desine an online address book to keep track of the names , addresses phone numbers, and birthdays of family members, close friends, and certain business associates. Your program should be able to handle a maximum of 500 entries. A. Define the class Address that can store a street address, city, state, and zip code. Use the appropriae methods to print and store the address. Also, use consructors to automatically initialize the data members. B. Define the class ExtPerson using the class Person (designed in chapter 8, example 8-8), the class Date, and the class Address. Add a data member to the class to claddify the person as a family member, friend, or business associate. Also, add a data member to store the phone number. Add (or override) methods to print and store the appropriate informatiom. Use constructors to automatically omotoa;ize the data members. C. Define the class AddressBook using previously defined classes. An object of…arrow_forward
- First, you need to design, code in Java, test and document a base class, Student. The Student class will have the following information, and all of these should be defined as Private: A first name (given name) A last name (family name/surname) Student number (ID) – an integer number (of type long) The Student class will have at least the following constructors and methods: (i) two constructors - one without any parameters (the default constructor), and one with parameters to give initial values to all the instance variables of Student. (ii) only necessary set and get methods for a valid class design. (iii) a reportGrade method, which you have nothing to report here, you can just print to the screen a message “There is no grade here.”. This method will be overridden in the respective child classes. (iv) an equals method which compares two student objects and returns true if they have the same student number (ID), otherwise it returns false. You may add other…arrow_forwardImplement the following parking permit class using java It has a dependency on the car class, no need to implement the car class. Use the diagram for refrencearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education