• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Triangle Class/Tester Program: returning 0's

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help!
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic