This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Help please!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help please!!" Watch "Help please!!" New topic

Help please!!

Nancy Bradley
Ranch Hand

Joined: Feb 25, 2004
Posts: 32
This program is suppose to calculate area and perimeter of a rectangle and an applet to test it.
When I run the program I can input the length and width, but the computer does not do any calculations
I can not figure it out
Thank you for your help and time
Nancy B
Nancy Bradley
Ranch Hand

Joined: Feb 25, 2004
Posts: 32
Sorry I forgot to type the code.
This is the Rectangle class
and here is the applet
[ edited to alleviate need to scroll left-right -ds ]
[ April 08, 2004: Message edited by: Dirk Schreckmann ]
Ashok C. Mohan
Ranch Hand

Joined: Dec 03, 2003
Posts: 75

Here the x and y are local to the methods,setting those values will not have any effect in mainx and mainy.try setting the mainx and mainy values instead of x and y in the setter methods....

SCJP 1.4
Do not dwell in the past, do not dream of the future, concentrate the mind on the present moment.
Amit Ghai
Ranch Hand

Joined: Mar 24, 2004
Posts: 35
you have done a small mistake.
in your setLength you are assigning value to x and y
change that to mainX and mainY. Then your program will display wt u want.
public void setLength(float x) // set length
mainX = ((x >= 1 & x < 20) ? x : 1); // range validation
public void setWidth(float y) // set width
mainY = ((y >= 1 & y < 20) ? y : 1); // range validation

Reasonable people adapt themselves to the world. Unreasonable people attempt to adapt the world to themselves. All progress, therefore, depends on unreasonable people.
I agree. Here's the link:
subject: Help please!!
It's not a secret anymore!