Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

profit and loss program

 
Ranch Hand
Posts: 424
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
had to write a profit and loss program
any criticism welcomed with open arms

ps"dont worry about package names etc, as this is only an exercise, though im still not really clear on how/what package names should be named...is it com.mydomain.www or something like that?"
 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are a few things I see.

First, congratulations on writing a good program!

* Get the code out of the main() method.  With a simple program like this it may not matter as much, but it is a good habit to get in.  Read why MainIsAPain (that's a link).
* Don't use floats unless you have too (which is rare).  Use doubles for better precision.
* The indentation is almost right, but you should format your code as you write.
* Minor: you can use System.out.print() to print a prompt without going to the next line.
 
Knute Snortum
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Package names should be unique.  The method used to keep them unique is the use a reverse domain name.  (This could be yours or the company you work for.)  Then add the project name.

So I own the domain snortum.net.  If I had a project called "foo", I would use the package
And it gets more complex than that, but that's the basic idea.
 
What a stench! Central nervous system shutting down. Save yourself tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic