• Post Reply Bookmark Topic Watch Topic
  • New Topic

Finding the biggest number in an array of numbers  RSS feed

 
Andrea Menjivar
Greenhorn
Posts: 25
1
Android
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI, I'm trying to practice writing a program where you need to get user input to fill up an array of 5 numbers then determine which is the biggest number. The output I keep getting is wrong and I end up just getting the last number input into the array instead of the biggest number. How should I fix this?

 
Liutauras Vilda
Marshal
Posts: 3961
214
BSD
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check line 23, very carefully. Character by character.
 
Paweł Baczyński
Bartender
Posts: 2006
42
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A hint.
This:Is the same as this:
 
Andrea Menjivar
Greenhorn
Posts: 25
1
Android
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:Check line 23, very carefully. Character by character.

Can't believe I glazed over that damn semicolon.
Thanks for your help
 
Liutauras Vilda
Marshal
Posts: 3961
214
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However, there are some things you may want to fix.

1. You may want to use some methods, as: printIntro(), fillAnArrayWithUsersNumbers (<- find better name), findLargestNumber()... printLargestNumber()...

2. Can you see another logic flaw in your for loop along with if statement? Hint: that happens during first iteration.
 
Liutauras Vilda
Marshal
Posts: 3961
214
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And by the way - have a cow for a nice code indentation and formatting.
 
Andrea Menjivar
Greenhorn
Posts: 25
1
Android
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:And by the way - have a cow for a nice code indentation and formatting.

Thanks! I appreciate it ^^
 
Campbell Ritchie
Sheriff
Posts: 54078
130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrea Menjivar wrote:. . . Can't believe I glazed over that damn semicolon.
Thanks for your help
Don't worry about it. Everybody else makes the same mistake.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!