Question: please help with this program JAVA Create a BlueJ project named: LabActivityClassesAndObjects Class: Cylinder Add code from: Participation Activity - Class Declaration and Instance Variables
please help with this program JAVA
Create a BlueJ project named: LabActivityClassesAndObjects
Class: Cylinder
- Add code from:
- Participation Activity - Class Declaration and Instance Variables
- Participation Activity - Constructors and Instance Methods
- Add Instance Method: Set Units
- Parameters: String
- Return Type: void
- Add Instance Method: Set Material
- Parameters: String
- Return Type: void
- Add Instance Method: Set Height
- Parameters: double
- Return Type: void
- Add Instance Method: Set Radius
- Parameters: double
- Return Type: void
Class: Lab Activity Classes And Objects
Main Method
- Add declarations from Participation Activity - Using Constructors and Calling Instance Methods
- Create Comment: Display Initial Values Display a description and the volume of Pin Display a description and the volume of Dowel
- Create Comment: User Input Get user input for Pin Units Get user input for Pin Material Get user input for Pin Height Get user input for Pin Radius
- Create Comment: Modifying Object Call the appropriate instance method to update the values of the Pin
- Create Comment: Final Values Display a description and the volume of Pin Display a description and the volume of Dowel
I have done class Cylinder and the first part of the main class please take a look
class Cylinder
public class Cylinder { // VARIALBES private double radius; private double height; private String units; private String material; // CONSTRUCTORS public Cylinder() { radius = 1.0; height = 1.0; units = "inches"; material = "Aluminum"; } public Cylinder(double cylinderRadius, double cylinderHeight, String cylinderUnits, String cylinderMaterial) { radius = cylinderRadius; height = cylinderHeight; units = cylinderUnits; material = cylinderMaterial; }
//METHODS public double volume() { return(height * Math.PI * Math.pow(radius, 2)); } public void setUnits(String units) { units = units; }
and here is part of the main class
public class LabActivityClassesAndObjects { public static void main(String[] args) { // CONSTANTS // VARIABLES // ARRAYS // OBJECTS Cylinder pin = new Cylinder(); Cylinder dowel = new Cylinder(5, 40, "mm", "Oak"); // Initial Values System.out.println("Pin volume: " + pin.volume() + " mm^2"); System.out.println("Dowel volume: " + dowel.volume() + " mm^2");
I need these parts
- Create Comment: User Input Get user input for Pin Units Get user input for Pin Material Get user input for Pin Height Get user input for Pin Radius
- Create Comment: Modifying Object Call the appropriate instance method to update the values of the Pin
- Create Comment: Final Values Display a description and the volume of Pin Display a description and the volume of Dowel
} }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
