Java please help, I am very confused on how to complete this assignment since ou
ID: 3793713 • 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.
Project: Dodecahedron App Page 1 of 4 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 retum 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 mo later than 1 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 ina zip file to your TA before the deadline. Files to submit to Web-CAT (both files must be submitted together: Dodecahedron java DodecahedronApp java Specifications overview: You will write a program this week that is composed of two classes: (1) one named Dodecahedron that defines D main method that reads in data, creates a Dodecahedron object, and then prints the object. A dodecahedron has 12 equal pentagonal faces, 20 vertices, and 30 edges as depicted below. The formulas are provided to assist you in computing return values for the respective Dodecahedron methods described in this project. Surface Area (A) A 3 /25+ 10 5 a Volume V) Edge length (a) 15 +7 /5 Surface/Volume ratio (A/V) Dodecahedronjava 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 (ie., a class instance) Page 1 of 4Explanation / Answer
Sample run 1:
Enter label, color, and edge length for a dodecahedron
label: Small Example
color: blue
edge: 0.25
Dodecahedron "Small Example" is "blue" with 30 edges of length 0.25 units.
surface area = 1.29 square units
volume = 0.12 cubic units
surface/volume Ratio = 10.777
Sample run 2:
Enter label, color, and edge length for a dodecahedron
label: Medium Example
color: orange
edge: 10.1
Dodecahedron "Medium Example" is "orange" with 30 edges of length 10.1 units.
surface area = 2,106.071 square units
volume = 7,895.319 cubic units
surface/volume Ratio = 0.267
Sample Run 3:
Enter label, color, and edge length for a dodecahedron
label: Large Example
color: silver
edge: 200.5
Dodecahedron "Large Example" is "silver" with 30 edges of length 200.5 units.
surface area = 829,963.459 square units
volume = 61,765,889.248 cubic units
surface/volume Ratio = 0.013
Sample Run 4:
Enter label, color, and edge length for a dodecahedron
label: Wrong edge
color: yellow
edge: 0
Error: edge must be greater than 0.
Dodecahedron.java:
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class Dodecahedron {
private String label="";
private String color="";
private double edge=0;
public Dodecahedron(String label, String color, double edge) {
setLabel(label);
setColor(color);
setEdge(edge);
}
public String getLabel() {
return label;
}
public boolean setLabel(String label) {
if(label!=null){
this.label = label.trim();
return true;
}
else return false;
}
public String getColor() {
return color;
}
public boolean setColor(String color) {
if(color!=null){
this.color = color.trim();
return true;
}
else return false;
}
public double getEdge() {
return edge;
}
public boolean setEdge(double edge) {
if(edge>0){
this.edge = edge;
return true;
}
else return false;
}
public double surfaceArea(){
return 3 * Math.sqrt(25 + (10*Math.sqrt(5))) * this.getEdge() *this.getEdge();
}
public double volume(){
return ((15 + (7*Math.sqrt(5)))/4) * this.getEdge() * this.getEdge() * this.getEdge();
}
public double surfaceToVolumeRatio(){
return surfaceArea()/volume();
}
@Override
public String toString() {
NumberFormat formatter = new DecimalFormat("#,##0.0##");
return "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(surfaceToVolumeRatio());
}
}
DodecahedronApp.java:
import java.util.Scanner;
public class DodecahedronApp {
public static void main(String[] args) {
String label,color;
double edge;
Scanner sc=new Scanner(System.in);
System.out.println("Enter label, color, and edge length for a dodecahedron");
System.out.print(" label: ");
label=sc.nextLine();
System.out.print(" color: ");
color=sc.nextLine();
System.out.print(" edge: ");
edge=Double.parseDouble(sc.nextLine());
if(edge<=0){
System.out.println("Error: edge must be greater than 0.");
}
else{
Dodecahedron dodecahedronObj=new Dodecahedron(label,color,edge);
System.out.println(dodecahedronObj);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.