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

Deliverables Your project files should be submitted to Web-CAT by the due date a

ID: 3912213 • Letter: D

Question

Deliverables Your project files should be submitted to Web-CAT by the due date and time specified. You submit your files to the skeleton code prior to the due date (there is no late penalty for the skelcton code assignment since this project). The files you submit to skeleton code assign method bodies have at least a return statement if applicable or they may be assignment until the project due date but should try to do this be incomplete in the sense that In order to avoid a late penalty for the project, you must submit your completed code files to it is ungraded for ment may essentially completed Web-CAT no later than 11:59 PM on the due date for the completed code. 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 mu st be submitted together): . Dodecahedron,java DodecahedronList. java . DodecahedronListMenuApp.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, DodecahedronListMenuApp, presents a menu to the user with eight options and implements these: (1 read input file (which creates a DodecahedronList object), (2) print report, (3) print summary, (4) add a Dodecahedron object to the DodecahedronList object, (5) delete a Dodecahedron object from the DodecahedronList object, (6) find a Dodecahedron object in the DodecahedronList object, (7) Edit a Dodecahedron in the DodecahedronList object, and (8) quit the program. [You should create a nevw "Project 6" folder and copy your Project 5 files (Dodecahedron,java, DodecahedronList.java, dodecahedron data 1.txt, and dodecahedron data 0.txt) to it, rather than work in the same folder as Project 5 files. A dodecahedron has 12 equal pentagonal faces, 20 vertices, and 30 edges as depicted below. The s are provided to assist you in computing return values for the respective Dodecahedron methods described in this project. Surface Area (A) Volume (V) Edge length (a) Surface/Volume ratio A/V) A 325+10y5 a 15+7,5 3

Explanation / Answer

import java.text.DecimalFormat;

public class Dodecahedron {
  
   private String label;
   private String color;
   private double edge;
  
   // parametrized constructor
   public Dodecahedron(String lbl, String clr, double edg)
   {
       label= lbl;
       color = clr;
       edge = edg;
   }

   public String getLabel() {
       return label;
   }

   public void setLabel(String label) {
       this.label = label;
   }

   public String getColor() {
       return color;
   }

   public void setColor(String color) {
       this.color = color;
   }

   public double getEdge() {
       return edge;
   }

   public void setEdge(double edge) {
       this.edge = edge;
   }
  
   public double surfaceArea()
   {
       return 3*Math.sqrt(25 + 10*Math.sqrt(5)) * edge* edge;
   }
  
   public double volume()
   {
       return ((15 + 7 * Math.sqrt(5)) / 4) * Math.pow(edge, 3);
   }
  
   public double surfaceToVolumeRatio()
   {
       return surfaceArea() / volume();
   }
  
   @Override
   public String toString()
   {
       DecimalFormat fmt = new DecimalFormat("#,##0.0##");
       return "Dodecahedron "" + label + "" is "" + color + "" with 30 " +
       " edges of length " + edge + "units. " +
       "surface area = " + fmt.format(surfaceArea()) + " square units" + " " +
       "volume = " + fmt.format(volume()) + " cubic units" + " " +
       "surface/volume ratio = " + fmt.format(surfaceToVolumeRatio());
   }
  

}

import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Scanner;

public class DodecahedronList {
  
   // instance variables
   private String listName;
   private ArrayList<Dodecahedron> dlist;
  
   public DodecahedronList(String name, ArrayList<Dodecahedron> dObjects)
   {
       listName = name;
       dlist = dObjects;
   }
  
   public String getName()
   {
       return listName;
   }
  
   public int numberOfDodecahedrons()
   {
       return dlist.size();
   }
  
   public double totalSurfaceArea()
   {
       double total = 0;
       for(Dodecahedron decahedron:dlist)
       {
           total += decahedron.surfaceArea();
       }
       return total;
   }
  
   public double totalVolume()
   {
       double total = 0;
       for(Dodecahedron decahedron:dlist)
       {
           total += decahedron.volume();
       }
       return total;
   }
  
   public double averageSurfaceArea()
   {
       int numDecah = numberOfDodecahedrons();
       if(numDecah == 0)
           return 0;
      
       return totalSurfaceArea() / numDecah;
   }
  
   public double averageVolume()
   {
       int numDecah = numberOfDodecahedrons();
       if(numDecah == 0)
           return 0;
      
       return totalVolume() / numDecah;
   }
  
   public double averageSurfaceToVolumeRatio()
   {
       return averageSurfaceArea() / averageVolume();
   }
  
   @Override
   public String toString()
   {
       String msg = "List: " + listName + " ";
       int i = 0;
       while(i < numberOfDodecahedrons())
       {
           msg += dlist.get(i).toString() + " ";
           i++;
       }
      
       return msg;
   }
  
   public String summaryInfo()
   {
       DecimalFormat fmt = new DecimalFormat("#,##0.0##");
       return "List: " + listName + " " +
               "Number of Decahedrons: " + numberOfDodecahedrons() + " " +
               "Total surface area: " + fmt.format(totalSurfaceArea()) + " " +
               "Total Volume: " + fmt.format(totalVolume()) + " " +
               "Average surface area: " + fmt.format(averageSurfaceArea()) + " " +
               "Average volume: " + fmt.format(averageVolume()) + " " +
               "Average surface/volume ratio: " + fmt.format(averageSurfaceToVolumeRatio());
   }
  
   public ArrayList<Dodecahedron> getList()
   {
       return dlist;
   }
  
   // This method needs to be implemented correctly
   // to implement it correctly the format of the text file is needed
   // to be observed. So please paste the text file in another question
    // post
   public ArrayList<Dodecahedron> readFile(String filename)

   {
       ArrayList<Dodecahedron> list = new ArrayList<Dodecahedron>();
       Scanner reader = null;
       try {
           reader = new Scanner(new File(filename));
       }
       catch (IOException e) {
          
           System.out.println("Error! Requested file was not found");
           System.exit(-1);
          
       }
      
       while(reader.hasNext())
       {
           reader.next();
       }
       return list;
   }
  
   public void addDecahedron(String lbl, String clr, double edge)
   {
       Dodecahedron dch = new Dodecahedron(lbl, clr, edge);
       dlist.add(dch);
   }
  
   public Dodecahedron findDecahedron(String label)
   {
       for(Dodecahedron dch:dlist)
       {
           if(dch.getLabel().equalsIgnoreCase(label))
               return dch;
       }
       return null;
   }
  
   public Dodecahedron deleteDodecahedron(String label)
   {
       for(int i = 0; i < numberOfDodecahedrons(); i++)
       {
           Dodecahedron dch = dlist.get(i);  
           if(dch.getLabel().equalsIgnoreCase(label))
           {
               dlist.remove(i);
               return dch;
           }
       }
       return null;
   }
  
   public boolean editDodecahedron(String lbl, String clr, double edge)
   {
       for(int i = 0; i < numberOfDodecahedrons(); i++)
       {
           if(lbl.equalsIgnoreCase(dlist.get(i).getLabel()))
           {
               dlist.get(i).setColor(clr);
               dlist.get(i).setEdge(edge);
               return true;
           }
       }
       return false;
   }

}

Imoprtant Note: The format of the text file is need to be observed to implement the readFile() method correctly in DodecahedronList class. So I have put that method incomplete but the class will compile successfully but the method will not work. So you need to put the text file in another question post along with the completed codes given above. Please note that you need DodecahedronListMenuApp class which would contain the main() method to run the Project

In the limited time I was able to complete the program as much was possible. The third class i.e., DodecahedronListMenuApp has not been compeleted due to limited time and unavailability of the input text file. So please post the required part in another question. Hope you understand the issue and won't give a negative feed back.

Thank you.

Dodecahedron.java

import java.text.DecimalFormat;

public class Dodecahedron {
  
   private String label;
   private String color;
   private double edge;
  
   // parametrized constructor
   public Dodecahedron(String lbl, String clr, double edg)
   {
       label= lbl;
       color = clr;
       edge = edg;
   }

   public String getLabel() {
       return label;
   }

   public void setLabel(String label) {
       this.label = label;
   }

   public String getColor() {
       return color;
   }

   public void setColor(String color) {
       this.color = color;
   }

   public double getEdge() {
       return edge;
   }

   public void setEdge(double edge) {
       this.edge = edge;
   }
  
   public double surfaceArea()
   {
       return 3*Math.sqrt(25 + 10*Math.sqrt(5)) * edge* edge;
   }
  
   public double volume()
   {
       return ((15 + 7 * Math.sqrt(5)) / 4) * Math.pow(edge, 3);
   }
  
   public double surfaceToVolumeRatio()
   {
       return surfaceArea() / volume();
   }
  
   @Override
   public String toString()
   {
       DecimalFormat fmt = new DecimalFormat("#,##0.0##");
       return "Dodecahedron "" + label + "" is "" + color + "" with 30 " +
       " edges of length " + edge + "units. " +
       "surface area = " + fmt.format(surfaceArea()) + " square units" + " " +
       "volume = " + fmt.format(volume()) + " cubic units" + " " +
       "surface/volume ratio = " + fmt.format(surfaceToVolumeRatio());
   }
  

}

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