aspose file tools*
The moose likes Beginning Java and the fly likes Triangle Class/Tester Program: returning 0's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Triangle Class/Tester Program: returning 0 Watch "Triangle Class/Tester Program: returning 0 New topic
Author

Triangle Class/Tester Program: returning 0's

Sandra Edwards-Thro
Greenhorn

Joined: Sep 07, 2012
Posts: 6
I am trying to calculate perimeter, hypotenuse, and area of a right triangle by making a RightTriangle class. I made one, and then had a basic program for testing it. The output is:
0.0
0.0
0.0

Which is not what I wanted. Why am I getting that? Any hints? (Pretty please?)

Note: I am using JCreator to write and compile this - that's what my teacher prefers.

Here is the code for the class:


Here is the code for the tester program:



"Flying is the art of throwing yourself at the ground and missing" -Hitchhiker's Guide to the Galaxy
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2286
    
  49
Please use Java naming standards for your variable names (they should start with lower case letters).

I suggest you take a close look at your constructor and in particular the first two lines.
Sandra Edwards-Thro
Greenhorn

Joined: Sep 07, 2012
Posts: 6
Thanks for your help!
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2286
    
  49
My pleasure.

When you run into a problem such as this, the first thing you should do is add some System.out.println() statements and print out the value of various variables to make sure they contain the value you think they should.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Triangle Class/Tester Program: returning 0's