Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot figure out what declaration to put in

 
matthew meltzer
Greenhorn
Posts: 24
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q17: What declaration needs to be added into line (1) in order for this program
to print out 90 to the standard output?


I'm trying to figure out exactly what I have to put at line 1 to make the program print out 90 but I am getting nowhere and all my efforts lead to compilation errors.
Could anyone help point me in the right direction?

Thank you,

-Matthew Meltzer

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What variable name is needed to make the code compile?

What type must it be? (There is actually more than one right answer to this one)

Start with these two and you'll get compiling code that doesn't print 90. Then try adding one value and seeing what gets printed. This will give you a clue as to the required values.
 
Henry Wong
author
Marshal
Pie
Posts: 20999
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
matthew meltzer wrote:Q17: What declaration needs to be added into line (1) in order for this program
to print out 90 to the standard output?


I'm trying to figure out exactly what I have to put at line 1 to make the program print out 90 but I am getting nowhere and all my efforts lead to compilation errors.
Could anyone help point me in the right direction?


Hint: what types of objects can be looped through by the for-each loop?

[EDIT: note to self ... when returning to your computer, make sure to click reload before responding -- as the question may already been answered... ]

Henry
 
matthew meltzer
Greenhorn
Posts: 24
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://ideone.com/9MX8Z

I keep getting an error regardless of how I change things.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"num" is correct on the line you added. int isn't the correct type. What types call you loop through using an enhanced for loop?
 
matthew meltzer
Greenhorn
Posts: 24
Eclipse IDE Firefox Browser Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
arrays. I should have known. Thanks!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yay! Thanks for bearing with us as you discovered the answer. You learn more that way. And we get to enjoy seeing you make the discovery!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic