• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help please!!

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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....
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
}
reply
    Bookmark Topic Watch Topic
  • New Topic