• Post Reply Bookmark Topic Watch Topic
  • New Topic

Missing Output While Incorporating A Class  RSS feed

 
B Mart
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would appreciate any assistance with this program. It compiles perfectly but I'm not getting any output. Thank you!





[HENRY: Added code tags]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not getting any output.

How did you execute it ?
 
Henry Wong
author
Sheriff
Posts: 23282
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The output when I ran it...

24 Oranges
at 10 for $2.99

36 Eggs
at 12 for $1.69

20 Apples
at 3 for $1.0

2 Watermelons
at 1 for $4.39

12 Bagels
at 6 for $3.5


Total: 34.69266666666667


Henry
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Total: 34.69266666666667

What currency is this ?
 
B Mart
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry, what program did you run it in? I wasn't getting any output in J Creator. Also, how can I reduce the decimals down to 2? I appreciate everyone's help!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran it in Eclipse and got the same output as Henry. You're probably not executing it properly under JCreator. I don't know that editor so I can't help further.
 
Campbell Ritchie
Sheriff
Posts: 55371
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

When I used JCreator, I usually used it as an editor and executed the code from the command line. Isn't there a project→run option? If you do that, do you see a window similar to a command line? That is where the output should be.
To get a certain number of places after the decimal point, try the % tags.

You have some peculiar design there. Why are you not setting those values via a constructor? You don't usually call a getXXX method without assigning its value to something, as you are doing.
 
B Mart
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know it's weird code. It's a program for an assignment and they give you the class of Purchase and you are supposed to use it to total the bill (oranges, apples, etc.)
 
B Mart
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
p.s. Thank you for the warm welcome!
 
Campbell Ritchie
Sheriff
Posts: 55371
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you got it to work yet? Have you tried compiling and running it from the command line?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!