Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

DodecahedronApp.java Requirements: Create a DodecahedronApp class with a main me

ID: 3904884 • Letter: D

Question

DodecahedronApp.java Requirements: Create a DodecahedronApp class with a main method that reads in values for label, color, and edge. After the values have been read in, main creates a D and then prints a new line and the object. odecahedron object Design: The main method should prompt the user to enter the label, color, and edge. After a value is read in for edge, if the value is less than or equal to zero, an appropriate message (see examples below) should be printed followed by a return from main. Assuming that edge is positive, a Dodecahedron object should be created and printed. Below is an example where the user has entered a non-positive value for edge followed by an example using the values from the first example above for label, color, and edge. Your program input/output should be exactt as follows. Page 3 of 4

Explanation / Answer

public class DodecahedronApp {

   public static void main(String[] args) {

       Scanner inOut = new Scanner(System.in);

       Dodecahedron dod = new Dodecahedron();

       DecimalFormat format = new DecimalFormat("##.00");

       System.out.println("Enter label, color, and edge length for a dodecahedron.");

       System.out.print("label: ");

       dod.setLabel(inOut.nextLine());

       System.out.print("color: ");

       dod.setColour(inOut.nextLine());

       System.out.print("edge: ");

       boolean valEdge = dod.setEdge(Double.parseDouble(inOut.nextLine()));

       if (!valEdge) {

           System.out.println("Error: edge must be greater than 0.");

       }

       else {

           System.out.println("Dodecahedron ""+dod.getLabel()+"" is ""+dod.getColour()+"" with 30 edges of length "+dod.getEdge()+" units.");

           double surfaceArea = dod.getSurfaceArea();

           double volume = dod.getVolume();

           double ratio = surfaceArea/volume;

           System.out.println("surface area = "+format.format(surfaceArea)+" square units");

           System.out.println("volume = "+format.format(volume)+" cubic units");

           System.out.println("surface/volume ratio = "+format.format(ratio));

       }

       inOut.close();

   }

  

}

class Dodecahedron {

   private String label;

   private String colour;

   private double edge;

  

   public String getLabel() {

       return label;

   }

  

   public void setLabel(String label) {

       this.label = label;

   }

   public String getColour() {

       return colour;

   }

   public void setColour(String colour) {

       this.colour = colour;

   }

   public double getEdge() {

       return edge;

   }

   public boolean setEdge(double edge) {

       if (edge > 0) {

       this.edge = edge;

       return true;

       }

       return false;

   }

  

   public double getVolume() {

       return 7.66 *edge*edge*edge;

   }

   public double getSurfaceArea() {

// these are the formula that i got after search you can change both volume and surface area formula according to your //findings.

       return 20.64*edge*edge;

   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote