# Dirt Track Volume

• 09-27-2012, 05:16 PM
v1ru5
Dirt Track Volume
http://gyazo.com/72d7bf6a9fcfaecb6f6...png?1348757685

Below is what I have completed until now but I am doing a test case and not getting the correct volume. If someone could help me out as to what I am doing wrong here it would be great.

Code:

import java.util.Scanner;

public class A1Q4
{  /**
* Calculate the volume required to cover the track
*/

public static void main( String[] args )
{
// SET UP KEYBOARD INPUT
Scanner keyboard = new Scanner( System.in );
// DECLARE VARIABLES/DATA DICTIONARY
double rLength = 0;
double rWidth = 0;
double tWidth = 0;
double depth = 0;
double clayVolume = 0;

// Read in the given values
System.out.print ("Please enter the width of the rectangle part of the inner field in meters: ");
rWidth = keyboard.nextDouble();
System.out.print ("Please enter the length of the rectangle part of the inner field in meters: ");
rLength = keyboard.nextDouble();
System.out.print ("Please enter the width of the track in meters: ");
tWidth = keyboard.nextDouble();
System.out.print ("Please enter the desired depth of clay in centimeters: ");
depth = keyboard.nextDouble();
// Call method to compute the volume of clay needed.

clayVolume = findClayVolume (rLength, rWidth, tWidth, depth);

// Diplay the result

System.out.println ("\nThe volume of clay needed to cover the track is " + clayVolume + " cubic metres");

}

/**
* Description:  include a description of the problem
*              solving method (algorithm).
* Parameters (GIVENS):
*/

private static double findClayVolume(double rLength, double rWidth, double tWidth, double depth)
{
// Declaration of the result variable
double clayVolume = 0;

// Declaration of the intermediate variables
double innerTrackVolume = 0;
double wholeTrackVolume = 0;
double depthInM = 0;

// Add code for the method
// Convert the depth in m
depthInM = depth/100;
// Calculate the inner track volume
innerTrackVolume = (rLength*rWidth*depthInM) + (4/3)*(Math.PI*Math.pow((rWidth/2),3)); //*(rWidth/2)*(rWidth/2));
// Calculate the whole track volume
wholeTrackVolume = (rLength*(rWidth + 2*tWidth)*depthInM) + (4/3)*(Math.PI*Math.pow(((rWidth + 2 * tWidth)/2),3)); //*((rWidth + 2 * tWidth)/2)*((rWidth + 2 * tWidth)/2));
// Calculate the track volume by subtracting whole track from inner track
clayVolume = wholeTrackVolume - innerTrackVolume;

// Return the result
return clayVolume;
}
}

• 09-27-2012, 06:37 PM
Norm
Re: Dirt Track Volume
Quote:

not getting the correct volume
Could you post what is on the console including what is entered and the results from the program and add some comments to it saying what the correct volume is?
• 09-27-2012, 06:57 PM
v1ru5
Re: Dirt Track Volume
Quote:

Originally Posted by Norm
Could you post what is on the console including what is entered and the results from the program and add some comments to it saying what the correct volume is?

The console output:

Please enter the width of the rectangle part of the inner field in meters: 300
Please enter the length of the rectangle part of the inner field in meters: 400
Please enter the width of the track in meters: 20
Please enter the desired depth of clay in centimeters: 70

The volume of clay needed to cover the track is 4842969.501221102 cubic metres

The volume of clay needed to cover the track is 25274.335088082244 cubic meters

Thanks for helping me out :)
• 09-27-2012, 07:05 PM
Norm
Re: Dirt Track Volume
Where did you get the correct answer?

Can you write formulas for computing the surface area for each section of the track?

If the straight sections were removed and the ends slide together, would the shape be a circle?
• 09-27-2012, 07:21 PM
v1ru5
Re: Dirt Track Volume
Yes, if you remove the two straight lines you will get two semicircles which you can combine to form a circle. The formulas were not given, I calculated the area by myself. This is what I did. First, I thought that if I get the volume of the inner track and find the volume of the whole track and do wholeTrackVolume - innerTrackVolume I would get the volume of the track that I want. Below is what I did to find the volume of inner track and whole track.

Inner Track:

To find the volume of the inner track I got the volume of the inner rectangle and added it to the volume of the two inner semicircles. So I know the volume of the rectangle is rLength * rWidth * depthInM (I converted depth from cm to m so all units match). To get the volume of the circle, I did (4/3)(PI*r^3). I added the volume of the rectangle and the volume of the circle to get the volume of the inner track.

Outer track:

I basically did the same thing except the width of the rectangle was rWidth + 2*tWidth. Also, to get the radius of the circle, instead of dividing rWidth by 2, I had to add tWidth*2 + rWidth then divide by two. When I added the two volumes I got the volume of the outer rectangle.

Then, as I said before, I did wholeTrackVolume - innerTrackVolume to get the volume that I need.

Please let me know if something does not make sense, I will try to explain it better.

Thanks

Edit: correct answer was given, I did not calculate it.
• 09-27-2012, 07:35 PM
Norm
Re: Dirt Track Volume
Are you covering the inner area? Or just the track part that is tWidth wide?

Can you write the formulas for each section you are computing the area of? Just the formulas.
• 09-27-2012, 07:44 PM
v1ru5
Re: Dirt Track Volume
I want to cover just the track part so yes, the part that is tWidth wide. I am not computing area, I am computer volume.

innerTrackVolume = (rLength*rWidth*depthInM) + (4/3)(PI*((rWidth/2)^3)

wholeTrackVolume = (rLength*(rWidth+2*tWidth)*depthInM) + (4/3)(PI*((rWidth+(2*tWidth))/2)^3)

Let me know if you need me to explain anything.
• 09-27-2012, 07:46 PM
Norm
Re: Dirt Track Volume
Not sure what you are computing.
I see the area as the sum of 2 rectangles and the difference between an outer circle and an inner circle.
• 09-27-2012, 07:53 PM
v1ru5
Re: Dirt Track Volume
Oh, I just understood what you said. Let me try it out and ill see what happens. Thanks for your help :)
• 09-27-2012, 08:06 PM
v1ru5
Re: Dirt Track Volume
Code:

rectangleTrack = (rLength*tWidth*depthInM)*2;
circleTrack = (4/3)*(Math.PI*Math.pow(((rWidth + (2 * tWidth))/2),3)) - (Math.PI*Math.pow((rWidth/2),3));
clayVolume = circleTrack + rectangleTrack;

So, as you suggested I added the two rectangle volumes. Then I took the large circle and subtracted by smaller one. I added the circle and rectangle but I am still getting the same answer so I guess it didn't matter which way I used to get the volume. I guess there is something wrong with my circle track, maybe I am doing something wrong to calculate its volume. Let me know if you find something.
• 09-27-2012, 08:29 PM
Norm
Re: Dirt Track Volume
What is the equation for the area of a circle?
• 09-27-2012, 08:57 PM
v1ru5
Re: Dirt Track Volume
Quote:

Originally Posted by Norm
What is the equation for the area of a circle?

I am not calculating the area, I am calculating the volume.

(4/3)(PI*r^3) = volume of a circle
(PI*r^2) = area of a circle
• 09-27-2012, 09:05 PM
Norm
Re: Dirt Track Volume
What shape are you calculating the volume of?

Quote:

volume of a circle
A circle does not have a volume. It is two dimensional. A sphere has a volume. A circle has an area.
• 09-27-2012, 09:56 PM
v1ru5
Re: Dirt Track Volume
Quote:

Originally Posted by Norm
What shape are you calculating the volume of?

A circle does not have a volume. It is two dimensional. A sphere has a volume. A circle has an area.

Yes, sorry. I am calculating the volume of the sphere, not circle.
• 09-27-2012, 10:07 PM
Norm
Re: Dirt Track Volume
Quote:

I am calculating the volume of the sphere
Why?
Have you ever seen or been to a race track? They are basically two dimensional. I've never seen one that looks like a sphere. Maybe for some kind of motorcycle sport.
• 09-27-2012, 10:10 PM
v1ru5
Re: Dirt Track Volume
Quote:

Originally Posted by Norm
Why?
Have you ever seen or been to a race track? They are basically two dimensional. I've never seen one that looks like a sphere. Maybe for some kind of motorcycle sport.

Hmm ya thats true. So I should not use volume of a sphere, I should use area of a circle. Let me try and I will let you know what happens. Thanks!
• 09-27-2012, 10:15 PM
v1ru5
Re: Dirt Track Volume
So this is what I did:

Code:

circleTrack = (Math.PI*Math.pow(((rWidth + (2 * tWidth))/2),2)) - (Math.PI*Math.pow((rWidth/2),2));
I got a output: The volume of clay needed to cover the track is 31306.192982974666 cubic metres

That is sort of closer to the expected result but still there is something wrong. Let me know if you find anything else. Thanks for your help.
• 09-30-2012, 02:05 AM
larryking923
Re: Dirt Track Volume
you are meant to calculate the area of a cylinder..... like you use Pi * (r)^2 * h to find the volume of the semi-circle... if you have any more problems i'll check back.
• 09-30-2012, 02:15 AM
Norm
Re: Dirt Track Volume
@v1ru5
Break the large expression up into a list of small simple steps that do one thing at a time. Putting it all into ONE expression is both hard to read and understand and makes it harder to debug.

With that technique ( 7 steps) I got: vol=25274.335088082265
• 09-30-2012, 02:21 AM
v1ru5
Re: Dirt Track Volume
Quote:

Originally Posted by Norm
@v1ru5
Break the large expression up into a list of small simple steps that do one thing at a time. Putting it all into ONE expression is both hard to read and understand and makes it harder to debug.

With that technique ( 7 steps) I got: vol=25274.335088082265

Norm and larry, thanks for your help :) I figured the answer out a little earlier but thanks for confirming :) Larry is right tat I am supposed to use PI*r^2 * h. Thanks again!