I am having trouble finding any logical errors...Any advise? Thank you
public class Brick
{
// Constant.
private static final int WEIGHT_PER_CM3 = 2; // weight per cubic cm
in grams
private int height;
private int width;
private int depth;
/**
* Create a Brick given edge lengths in centimeters.
* @param height The brick's height.
* @param width The brick's width.
* @param depth The brick's depth.
*/
public Brick(int height, int width, int depth)
{
this.height = height;
this.width = width;
this.depth = depth;
}
/**
* @return The surface area of this brick in square
centimeters.
*/
public double getSurfaceArea()
{
double side1 = width * height;
double side2 = width * depth;
double side3 = depth * height;
double total = (side1 + side1 + side3) * 2;
return total;
}
/**
* @return The weight of this brick in kg.
*/
public double getWeight()
{
return (getVolume() * WEIGHT_PER_CM3) / 1000;
}
/**
* @return The volume of this brick in cubic centimeters.
*/
public int getVolume()
{
return width * height * depth;
}
/**
* @return The height of this brick in centimeters.
*/
public double getHeight()
{
return height;
}
}
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
I am having trouble finding any logical errors...Any advise? Thank you public class Brick { //...
I am trying to write a Geometry.java program but Dr.Java is giving me errors and I dont know what I am doing wrong. import java.util.Scanner; /** This program demonstrates static methods */ public class Geometry { public static void main(String[] args) { int choice; // The user's choice double value = 0; // The method's return value char letter; // The user's Y or N decision double radius; // The radius of the circle double length; // The length of...
Assignment (to be done in Java):
Person Class:
public class Person extends Passenger{
private int numOffspring;
public Person() {
this.numOffspring = 0;
}
public Person (int numOffspring) {
this.numOffspring = numOffspring;
}
public Person(String name, int birthYear, double weight, double
height, char gender, int numCarryOn, int numOffspring)
{
super(name, birthYear, weight, height, gender,
numCarryOn);
if(numOffspring < 0) {
this.numOffspring = 0;
}
this.numOffspring = numOffspring;
}
public int getNumOffspring() {
...
(Need to complete the methods and pass a Junit test i can email them to you.) public class Triangle implements Comparable { /** * Stores the number of objects instantiated from the {@code Triangle} class */ private static int numTriangles; /** * The shortest side of the triangle */ private final double a; /** * The side of medium length of the triangle */ private final double b;...
public class CylindricalTank { private String idTag; // Unique String identifying the tank private double radius; // The non-negative radius of the base of the tank in meters private double height; // The non-negative height of the tank in meters private double liquidLevel; // The current height of the liquid in the tank in meters /** * CylindricalTank General Constructor */ public CylindricalTank(String tag, double...
Hi, I am having trouble solving the constructor, it requires to ArrayList marks to be a deep copy of the instance variable. I have also provided the J-Unit test I have been provided. import java.util.*; public class GradebookEntry { private String name; private int id; private ArrayList<Double> marks; /** * DO NOT MODIFY */ public String toString() { String result = name+" (ID "+id+")\t"; for(int i=0; i < marks.size(); i++) { /** * display every mark rounded off to two...
I need help with my java code i am having a hard time compiling it // Cristian Benitez import java.awt.Color; import java.awt.Graphics; import java.util.ArrayList; import javax.swing.JPanel; Face class public class FaceDraw{ int width; int height; int x; int y; String smileStatus; //default constructor public FaceDraw(){ } // Getters and Setters for width,height,x,y public int getWidth(){ return width; } public void setWidth(int width){ this.width=width; } public int getHeight(){ return height; } public void setHeight(int height){ this.height=height; } public int getX(){ return...
I have a program that reads a file and then creates objects from the contents of the file. How can I create a linked list of objects and use it with the package class instead of creating and using an array of objects? I am not allowed to use any arrays of objects or any java.util. lists in this program. Runner class: import java.util.Scanner; import java.io.*; class Runner { public static Package[] readFile() { try { File f = new...
I have done a decent amount of coding... but I need you to help me understand what I do not. Please, post comments so that I can learn from you. Here are the instructions for this portion of the project: Create the Monkey class, using the specification document as a guide. The Monkey class must do the following: Inherit from the RescueAnimal class Implement all attributes with appropriate data structures Include accessors and mutators for all implemented attributes Here is...
package hw2; public class SandBox { private final double length; // doesn't change after SandBox is constructed private final double width; // doesn't change after SandBox is constructed private final double height;// doesn't change after SandBox is constructed // current height of the sand within the box private double sandHeight; /* * Constructor * Initially there is no sand in this SandBox */ public SandBox(double length, double width, double...