• Post Reply Bookmark Topic Watch Topic
  • New Topic

Clean up  RSS feed

 
Adrian Martinez
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,

This code has no issues, but is there another way this could have been made cleaner/neater or did i get the basics correct?


 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be a good habit to start avoiding floating point data types (like float and double) to represent monetary values, because those values will always need to be exact and floating point data types just don't offer that accuracy. Use BigDecimal instead, or possibly even int or long if the situation allows for it. Also, are you worried at all about Object Orientation at this point or are you just familiarizing yourself with the basics of Java?

 
Adrian Martinez
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm taking a class on java, so i'm just learning the basics.

 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not much to say about the code itself - it's just basic calculations and output. you should learn how to format your code better though. And follow coding conventions. Class names are capitalized.

You should use spaces instead of hard tabs to indent your code. Tabs can get expanded differently in different editors/viewers.
 
Adrian Martinez
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have only been using notepad to edit/view the code.

But I see what you are saying along with the capitalization.
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adrian Martinez wrote:I have only been using notepad to edit/view the code.

Consider switching to Notepad++ or some other programmer's editor for Windows. Notepad sucks.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Move all that code out of the main method.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:
Adrian Martinez wrote:I have only been using notepad to edit/view the code.

Consider switching to . . . Notepad sucks.
Couldn't agree more. A few more suggestions here and here.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!