subject

Public class DebugBox {
private int width;
private int length;
private int height;
public DebugBox()
{
length = 1;
width = 1;
height = 1;
}
public DebugBox(int width, int length, int height)
{
width = width;
length = length;
height = height;
}
public void showData()
{
System. out. println("Width: " + width + "Length: " +
length + "Height: "+ height);
}
public double getVolume()
{
double vol = length * width * height;
return vol;
}
}

// This class uses a DebugBox class to instantiate two Box objects
public class DebugFour3
{
public static void main(String args[])
{
int width = 12,
length = 10,
height = 8;
DebugBox box1 = new DebugBox();
DebugBox box2 = new DebugBox(width, length, height);
System. out. println("The dimensions of the first box are");
box1.showData();
System. out. print("The volume of the first box is ");
showVolume(box1);
System. out. println("The dimensions of the second box are");
box2.showData();
System. out. print("The volume of the second box is ");
showVolume(box2);
}
public static void showVolume(DebugBox aBox)
{
double vol = aBox. getVolume();
System. out. println(vol);
}
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:00
Suppose an astronomer discovers a large, spherical-shaped body orbiting the sun. the body is composed mostly of rock, and there are no other bodies sharing its orbit. what is the best way to categorize this body? a. planet b. moon c. comet d. asteroid
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
What is used to analyze and summarize your data without graphical support
Answers: 1
question
Computers and Technology, 22.06.2019 21:00
Write a method so that the main() code below can be replaced by the simpler code that calls method original main(): public class calcmiles { public static void main(string [] args) { double milesperhour; double minutestraveled; double hourstraveled; double milestraveled; milesprhour = scnr.nextdouble(); minutestraveled = scnr.nextdouble(); hourstraveled = minutestraveled / 60.0; milestraveled = hourstraveled * milesperhour; system.out.println("miles: " + milestraveled); } }
Answers: 2
question
Computers and Technology, 22.06.2019 22:50
Assume the existence of a bankaccount class. define a derived class, savingsaccount that contains two instance variables: the first a double, named interestrate, and the second an integer named interesttype. the value of the interesttype variable can be 1 for simple interest and 2 for compound interest. there is also a constructor that accepts two parameters: a double that is used to initialize the interestrate variable, and a string that you may assume will contain either "simple", or "compound", and which should be used to initialize the interesttype variable appropriately. there should also be a pair of functions getinterestrate and getinteresttype that return the values of the corresponding data members (as double and int respectively).
Answers: 2
You know the right answer?
Public class DebugBox {
private int width;
private int length;
private int height...
Questions
question
Mathematics, 03.10.2019 07:10
Questions on the website: 13722360