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

Java please help, I am very confused on how to complete this assignment since ou

ID: 3799228 • Letter: J

Question

Java please help, I am very confused on how to complete this assignment since our professor barely covered it and I lack prior coding experience.

Requirements: Create a Dodecahedron class that stores the label, color, and edge (i.e., length of
an edge, which must be greater than zero). The Dodecahedron class also includes methods to set
and get each of these fields, as well as methods to calculate the surface area, volume, and surface
to volume ratio of a Dodecahedron object, and a method to provide a String value of a Dodecahedron object (i.e., a class instance).

Project: Dodecahedron List App Page 1 of7 DeliverableS Your project files should be submitted to Web-CAT by the due date and time specified. You may submit your files to the skeleton code assignment until the project due date but should try to do this by Friday (there is no late penalty since the skeleton code assignment is ungraded for this project). The files you submit to skeleton code assignment may be incomplete in the sense that method bodies have at least a return statement if applicable or they may be essentially completed files. In order to avoid a late penalty for the project, you must submit your completed code files to Web-CAT no later than 11:59 PM on the due date for the completed code. You may submit your completed code up to 24 hours after the due date, but there is a late penalty of 15 points. No projects will be accepted after the one-day late period. If you are unable to submit via Web-CAT, you should e-mail your project Java files in a zip file to your TA before the deadline Files to submit to Web-CAT (all three files must be submitted together): Dodecahedron.java DodecahedronList.java DodecahedronListApp.java Specifications Overview: You will write a program this week that is composed of three classes: the first class defines Dodecahedron objects, the second class defines DodecahedronList objects, and the third, DodecahedronListApp, reads in a file name entered by the user then reads the list name and Dodecahedron data from the file, creates Dodecahedron objects and stores them in an ArrayList, creates a DodecahedronList object with the list name and ArrayList, prints the DodecahedronList object, and then prints summary information about the DodecahedronList object. A dodecahedron has 12 equal pentagonal faces, 20 vertices, and 30 edges as depicted below. The ormulas are provided to assist you in computing return values for the respective Dodecahedron described in this project. Surface Area (A) Volume (V) Edge length (a) Surface/Volume ratio (A/V) A = 3,25 +10)/5 a. Cl 15+7/5 Dodecahedron.java (assuming that you successfully created this class in Project 4,just copy the file to your new Proiect 5 folder and go on to DodecahedronList.iava on page 4 Otherwise, you will need to create Dodecahedron.iava as part of this project.) Page 1 of7

Explanation / Answer

Solution: See the code below:

1. Dodecahedron class: Dodecahedron.java

-----------------------------------

package dodecahedron;

import java.text.DecimalFormat;
import java.text.NumberFormat;

/**
* Dodecahedron class
*
*/
public class Dodecahedron {
  
   //class members
   private String label; //label of dodecahedron
   private String color; //color of dodecahedron
   private double edge; //length of edge

   /**
   * Constructor
   */
   public Dodecahedron() {      
       label="";
       color="";
       edge=0.0;
   }
  
   /**
   * @param label
   * @param color
   * @param edge
   */
   public Dodecahedron(String label, String color, double edge) {
       setLabel(label);
       setColor(color);
       setEdge(edge);;
   }

   /**
   * @return the label
   */
   public String getLabel() {
       return label;
   }

   /**
   * @param label the label to set
   */
   public void setLabel(String label) {
       this.label = label;
   }

   /**
   * @return the color
   */
   public String getColor() {
       return color;
   }

   /**
   * @param color the color to set
   */
   public void setColor(String color) {
       this.color = color;
   }

   /**
   * @return the edge
   */
   public double getEdge() {
       return edge;
   }

   /**
   * @param edge the edge to set
   */
   public void setEdge(double edge) {
       this.edge = edge;
   }
  
   /**
   * @return surface area
   */
   public double surfaceArea()
   {
       return (Math.cbrt(25+(10*Math.sqrt(5)))*(edge*edge));
   }
  
   /**
   * @return volume
   */
   public double volume()
   {
       return (((15+7*Math.sqrt(5))/4)*(edge*edge*edge));
   }
  
   /**
   * @return surface area to volume ratio
   */
   public double surfaceVolumeRatio()
   {
       return (surfaceArea()/volume());
   }

   /* (non-Javadoc)
   * @see java.lang.Object#toString()
   */
   @Override
   public String toString() {
       NumberFormat formatter = new DecimalFormat("#,##0.0##");
       String val = "Dodecahedron "+'"' + getLabel() +'"' + " is" + '"' + getColor() + '"' + " with 30 edges of length" + getEdge() + "units." +
                   " surface area = " + formatter.format(surfaceArea()) + " square units" +
                   " volume = " + formatter.format(volume()) + " cubic units" +
                   " surface/volume ratio = " + formatter.format(surfaceVolumeRatio());
       return val;
   }  
}

--------------------------------------------------

2. DodecahedronList class: DodecahedronList.java

----------------------------------------------------

package dodecahedron;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;

/**
* DodecahederonList class
*
*/
public class DodecahederonList {
  
   //class members
   private String dodecahedronListName; //name of list
   private ArrayList<Dodecahedron> dodecahedrons; //array list containing dodecahedron objects
   /**
   * @param dodecahedronListName
   * @param dodecahedrons
   */
   public DodecahederonList(String dodecahedronListName, ArrayList<Dodecahedron> dodecahedrons) {
       this.setDodecahedronListName(dodecahedronListName);
       this.dodecahedrons = dodecahedrons;
   }
   /**
   * @return the dodecahedronListName
   */
   public String getDodecahedronListName() {
       return dodecahedronListName;
   }
   /**
   * @param dodecahedronListName the dodecahedronListName to set
   */
   public void setDodecahedronListName(String dodecahedronListName) {
       this.dodecahedronListName = dodecahedronListName;
   }

   /**
   * @return number of dodecahedrons
   */
   public int numberOfDodecahedrons()
   {
       return dodecahedrons.size();
   }
  
   /**
   * @return total surface area of all dodecahedrons in list
   */
   public double totalSurfaceArea()
   {
       double area=0.0;
       for (Dodecahedron dodecahedron : dodecahedrons) {
           area+=dodecahedron.surfaceArea();
       }
       return area;
   }
  
   /**
   * @return total volume of all dodecahedrons in list
   */
   public double totalVolume()
   {
       double volume=0.0;
       for (Dodecahedron dodecahedron : dodecahedrons) {
           volume+=dodecahedron.volume();
       }
       return volume;
   }
  
   /**
   * @return average surface area of all dodecahedrons in list
   */
   public double averageSurfaceArea()
   {
       double averageArea=0.0;
       if(dodecahedrons.size()!=0)
           averageArea=totalSurfaceArea()/dodecahedrons.size();
       return averageArea;
   }
  
   /**
   * @return average volume of all dodecahedrons in list
   */
   public double averageVolume()
   {
       double averageVolume=0.0;
       if(dodecahedrons.size()!=0)
           averageVolume=totalVolume()/dodecahedrons.size();
       return averageVolume;
   }
  
   /**
   * @return average surface to volume ration for all dodecahedrons in list.
   */
   public double averageSurfaceToVolumeRatio()
   {
       return ((dodecahedrons.size()!=0)?(averageSurfaceArea()/averageVolume()):0.0);
   }
   /* (non-Javadoc)
   * @see java.lang.Object#toString()
   */
   @Override
   public String toString() {
       return "DodecahederonList [dodecahedronListName=" + dodecahedronListName + ", dodecahedrons=" + dodecahedrons
               + "]";
   }
  
   public String summaryInfo()
   {
       NumberFormat formatter = new DecimalFormat("#,##0.0##");
       return "DodecahederonList [Name="+dodecahedronListName+
               " Number of Dodecahedrons="+numberOfDodecahedrons()+
               " Total Surface Area="+formatter.format(totalSurfaceArea())+
               " Total Volume="+formatter.format(totalVolume())+
               " Average Surface Area="+formatter.format(averageSurfaceArea())+
               " Average Volume="+formatter.format(averageVolume())+
               " Average Surface To Volume Ratio="+formatter.format(averageSurfaceToVolumeRatio());
   }
}

------------------------------------------------

3. DodecahedronListApp class: DodecahedronListApp.java

---------------------------------------------

package dodecahedron;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

/**
* DedecahedronListApp class
*
*/
public class DodecahedronListApp {

   /**
   * @param args
   */
   public static void main(String[] args) {
       // TODO Auto-generated method stub
       System.out.println("Enter name of file:");
       String filename="";
       Scanner in=new Scanner(System.in);
       filename=in.next();
       try {
           BufferedReader reader= new BufferedReader(new FileReader(new File(filename)));
           int linesRead=0;
           String listName="";
           String line="";
           ArrayList<Dodecahedron> dodecahedrons=new ArrayList<Dodecahedron>();
           String name="", color="";
           double edge=0.0;
           int counter=0;
           while((line=reader.readLine())!=null)
           {
               linesRead++;
               if(linesRead==1)
               {
                   listName=line;                  
               }
               else
               {
                   counter++;
                   switch(counter)
                   {
                   case 1:
                       name=line;
                       break;
                   case 2:
                       color=line;
                       break;
                   case 3:
                       edge=Double.parseDouble(line);
                       Dodecahedron dodecahedron=new Dodecahedron(name, color, edge);
                       dodecahedrons.add(dodecahedron);
                       name="";
                       color="";
                       edge=0.0;
                       counter=0;
                       break;
                   }
               }
           }
           DodecahederonList dodecahederonList=new DodecahederonList(listName, dodecahedrons);
           System.out.println("Dodecahedrons'list:");
           System.out.println(dodecahederonList.toString());
           dodecahederonList.summaryInfo();
       } catch (FileNotFoundException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
       } catch (IOException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
       }
       in.close();
   }
}

--------------------------------------------------

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