Welcome to Dream.In.Code
Become a Java Expert!

Join 149,613 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,856 people online right now. Registration is fast and FREE... Join Now!




Tank Drainer program gives me 0 for area...help?

 
Reply to this topicStart new topic

Tank Drainer program gives me 0 for area...help?

mezig101
18 Aug, 2007 - 04:18 PM
Post #1

D.I.C Head
**

Joined: 1 Aug, 2007
Posts: 54


My Contributions
K so my code is

[

/**
* Write a description of class Tank here.
*
* @author (your name)
* @version (a version number or a date)
*/

import java.util.Scanner;
class Tank
{
double TankRadius;
double TankArea = Math.PI * TankRadius * TankRadius;
double TankVolume;
double HoleRadius;
double HoleArea;
double VelocityoutofTank;
double VolumeLost;
double NewVolumeInTank;
double FuelHeight = 20;
double TankDiameter = 10;
double HoleDiameter = 2;
double WaterHeight;

double TankRadius()
{
return (TankDiameter) / 2;
}

double TankArea()
{
return Math.PI * TankRadius * TankRadius;
}

double TankVolume()
{
return FuelHeight * TankArea;
}

double HoleRadius()
{
return HoleDiameter / 2;
}

double HoleArea()
{
return Math.PI * HoleRadius * HoleRadius;
}

double VelocityoutofTank()
{
return 8.02 * Math.sqrt(WaterHeight);
}

double VolumeLost()
{
return VelocityoutofTank * HoleArea * 1;
}

double NewVolumeInTank()
{
return TankVolume - VolumeLost;
}

double FuelHeight()
{
return NewVolumeInTank / TankArea;
}

}

public class TankDrainer
{
public static void main (String[ ] args)
{

Scanner in = new Scanner(System.in);
Tank drainer = new Tank();
double TankRadius;

System.out.println("The tank radius: " + drainer.TankRadius());
TankRadius = in.nextDouble();
System.out.println("The tank area: " + drainer.TankArea());
System.out.println("The tank volume: " + drainer.TankVolume());
System.out.println("The hole radius: " + drainer.HoleRadius());
System.out.println("The hole area: " + drainer.HoleArea());
System.out.println("The Velocity out of tank: " + drainer.VelocityoutofTank());
System.out.println("The Volume Lost: " + drainer.VolumeLost());
System.out.println("The New Volume In Tank: " + drainer.NewVolumeInTank());
System.out.println("The Fuel Height: " + drainer.FuelHeight());

}

]


but I get 0 for tank area, volume, hole area, velocity out of tank..etc

can you plz tell me what im doing wrong?
User is offlineProfile CardPM
+Quote Post

alpha02
RE: Tank Drainer Program Gives Me 0 For Area...help?
18 Aug, 2007 - 08:37 PM
Post #2

D.I.C Addict
Group Icon

Joined: 20 May, 2006
Posts: 687


Dream Kudos: 850
My Contributions
I don't see any instruction where you initialized your variables, so by default they are all 0. When calculating the surface, the program calculates:

CODE
PI * radius^2
3.14*0^2
0


Initializing (giving an initial value to) your variables may solve the problem.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 12:25AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month