• 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

It's not working

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SO I am trying to finish an overdue Lab.... I have been putting this off because I don't understand what I am doing wrong.

Here is what I need to be able to do.
"Your job is to complete the program. When it is complete, the program will ask the user to enter the width and length of a rectangle, and then display the rectangle’s area. The program calls the following methods, which have not been written:
• getLength—This method should ask the user to enter the rectangle’s length, and then return that value as a double.
• getWidth—This method should ask the user to enter the rectangle’s width, and then return that value as a double.
• getArea—This method should accept the rectangle’s length and width as arguments, and return the rectangle’s area. The area is calculated by multiplying the length by the width.
• displayData—This method should accept the rectangle’s length, width, and area as arguments, and display them in an appropriate message on the screen.

Copy the source code and the output into a word processing document and submit the file."

This is what I have so far. Netbeans is telling me that nothing is wrong but it isnt working right....

I dont understand what I am doing wrong.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to provide more details.

When you say "It isn't working right" you need to tell us EXACTLY what you're expecting your program to do and then what EXACTLY it's actually doing.

Also, for future reference, please UseCodeTags when you post code.
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And Welcome to the Ranch!
 
Rykota Banehoof
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry about that Junilu that was my first post and I am more worried about getting my work done then figuring out this this site.... Just really frustrated right now.

When I push the "Run" button on NetBeans it is coming up with something completely different then what I want.

run:
enter start number: 6
enter end number: 14
enter increment: 2
6
8
10
12
14
BUILD SUCCESSFUL (total time: 13 seconds)

When it should be coming up with:

"The length is "
"The width is "
"The area is: "
And then DisplayData.

& thank you for the Welcome.

I hope this helps?
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Refer to this document: https://docs.oracle.com/cd/E50453_01/doc.80/e50452/run_debug_japps.htm and follow the instructions in section 9.4 Running a Single File
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, refer to https://docs.oracle.com/javase/tutorial/getStarted/cupojava/netbeans.html

The second bullet point in the last section at the bottom of that page explains what's going on when you select Run vs Run File. I guess "Run" is synonymous with "Run Main Project" and you have another class set as the main class for the current project your editing.
 
Rykota Banehoof
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Didnt answer what I needed but thanks anyway.
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem. If you find something that works, we'd appreciate you sharing it here on this thread so others might benefit from your experience. Thanks.
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyway: how are you getting on with the code? Have you tried running the code from the command line, which should be easy enough if you only have one .java file?
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rykota Banehoof wrote:Didnt answer what I needed but thanks anyway.



What happened when you tried Junilu's suggestion? Did you get the same result?

The implication of your output is that it was running a different class to the one you expected.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic