• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing data for calculations  RSS feed

 
Derek Smiths
Ranch Hand
Posts: 119
Eclipse IDE Mac VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've created a method to calculate the ratio of one vowel to another, but I was hoping to get some feedback on another way I could approach the problem. The first bit of code is to find the vowels and assign them to an array ( for me, it seemed the easier thing to do in order to easily access the data). In the other bit of code, I have a method with two arguments (the vowels) to calculate the ratio. I'm sure there is a better way to do this...could someone enlighten me. haha


 
Knute Snortum
Sheriff
Posts: 4276
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like good code. Here is a thought: you have what are called "magic numbers" in your code, that is, vowelCounter[0] is a, 1 is b, and so forth. You can make the code easier to understand by creating constants with self documenting names, e.g:


Maybe an even better way to deal with this is to use a Map for your vowelCounter.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!