Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Triangle Class/Tester Program: returning 0's

 
Sandra Edwards-Thro
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
Tony Docherty
Bartender
Posts: 2965
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help!
 
Tony Docherty
Bartender
Posts: 2965
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic