• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Values in array not stored?

 
Greenhorn
Posts: 14
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nevermind, I just forgot to increment n while trying to store the humidity... I do this every time and I suddenly realize what I did wrong when I post it online...

My problem is that after printing humidity[n] in the "Humidity(%)" row, it seems that humidity[n] becomes 0. I checked like this:



In the "Humidity(%)" row, they come out fine, but when I do this, they come out as 0, which I think would explain why my heat indices are consistently lower than the temperature when the temperature is over 80.

My code:

 
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for keeping up your code and using code tags. Can I make a suggestion about your code?

The general rule is not to have line over 80 characters. This seems short, but it help in a lot of situations.

Lines 78 and 79 are both long and cryptic. The use of "magic numbers" is discouraged. A magic number is one that isn't patently obvious (e.g. 1/2) that is not explained or better yet, stored in a variable. -42.379 may mean something to you, but it doesn't to me.

"tempDoubleArray[]" is not a good name. I can tell it's a double array by looking at the code. What does it do? What is it for?

 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Damien Sky wrote:Nevermind, I just forgot to increment n while trying to store the humidity... I do this every time and I suddenly realize what I did wrong when I post it online...



It's the action of of mentally constructing your question that gives your brain a chance to analyse the problem.
I get this all the time when I present a problem I've encountered to a colleague and, just as I'm getting to the end of explaining the problem, go "Ah! That's it!".
 
Marshal
Posts: 74348
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote: . . . . A magic number is one that isn't patently obvious (e.g. 1/2) . . .

Agree. It is much quicker to write 0.
 
Damien Sky
Greenhorn
Posts: 14
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That was just the formula I was given.
 
Knute Snortum
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Damien Sky wrote:That was just the formula I was given.



Fair enough, but you can still break it into smaller lines and format it a bit. Long lines in programs mess up the screen for some users and they're hard to read.

 
Damien Sky
Greenhorn
Posts: 14
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. I understand that.
 
reply
    Bookmark Topic Watch Topic
  • New Topic