Question: this is java program please help to create input dialog for these methods and the bottom i provide the code for two classes Class: Classes

this is java program please help to create input dialog for these methods and the bottom i provide the code for two classes

Class: Classes And Objects Graphical User Interface

  • Create Method: Unit Input using an Input Dialog.
  • Create Method: Material Input using an Input Dialog.
  • Create Method: Height Input using an Input Dialog, Error Message Dialog, and Double.parseDouble.
  • Create Method: Radius Input using an Input Dialog, Error Message Dialog, and Double.parseDouble.
  • Create Method: Volume Output using a Message Dialog.
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 newUnits) { units = newUnits; } public void setMaterial(String newMaterial) { material = newMaterial; } public void setHeight(double newHeight) { height = newHeight; } public void setRadius(double newRadius) { radius = newRadius; } public double getRadius() { return radius; } public double getHeight() { return height; } public String getUnits() { return units; } public String getMaterial() { return material; } }

======================================================================

import java.util.Scanner; 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"); Scanner keyBoardInput = new Scanner(System.in); // Initial Values System.out.println("Pin volume: " + pin.volume() + " mm^3"); System.out.println("Dowel volume: " + dowel.volume() + " mm^3"); // User Input System.out.println("Please enter the units: "); String units = keyBoardInput.nextLine(); System.out.println("Please enter the material: "); String material = keyBoardInput.nextLine(); System.out.println("Please enter the height: "); double height = keyBoardInput.nextDouble(); System.out.println("Please enter the radius: "); double radius = keyBoardInput.nextDouble(); // Modifying Object pin.setUnits(units); pin.setMaterial(material); pin.setHeight(height); pin.setRadius(radius); //Create Comment:Final Values //Display a description and the volume of Pin System.out.println("Pin Object"); System.out.printf("Radius: %.2f, Height: %.2f, Units: %s, Material: %s ", pin.getRadius(), pin.getHeight(), pin.getUnits(), pin.getMaterial()); System.out.printf("Volume: %.2f %s^3 ", pin.volume(),pin.getUnits()); System.out.println(); //Display a description and the volume of Dowel System.out.println("Dowel Object"); System.out.printf("Radius: %.2f, Height: %.2f, Units: %s, Material: %s ", dowel.getRadius(), dowel.getHeight(), dowel.getUnits(), dowel.getMaterial()); System.out.printf("Volume: %.2f %s^3 ", dowel.volume(),dowel.getUnits()); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!